Hi
I am trying to use below code (Google Apps Script) to get data from Airtable. The fetch request succeeds but the fields are returned as text [Object]. I am not able to see actual data. However the request works from other HTTP clients like Bruno.
I have observed another issue. The code with small change marked below used to return data perfectly till couple of days ago but suddenly started throwing error 422. Hence I made below change and the result is missing data.
Even GET method results same.
Please suggest how this can be resolved as this is a show stopper.
Currently the result is like below
{ id: 'recrR654MViYPpGG5', createdTime: '2024-01-30T10:38:29.000Z', fields: [Object] }
My code is as below
let invoicenumin = "EI000002"
const scriptProperties = PropertiesService.getScriptProperties();
airdbKey = scriptProperties.getProperty('airdbkey')
const fieldObj = [
"quantity",
"unitprice",
"lineamount",
"itemdescription"
]
let filter = "{invoicenum} = " + '\''+invoicenumin +'\''
const atdata = {
//"records": [{"fields": fieldObj}] /* this used to WORK EARLIER, BUT STOPPED SUDDENLY AND NOW THROWING ERROR 422*/
"fields": fieldObj,
"filterByFormula": filter
}
const options =
{
"contentType": 'application/json',
"headers" : { "Authorization": "Bearer "+airdbKey },
"method" : 'POST',
'payload' : JSON.stringify(atdata)
};
const API_URL ='https://api.airtable.com/v0/<myappid>/Invoiceline/listRecords'
console.log('Options are', options)
const retval = UrlFetchApp.fetch(API_URL,options)