Error when calling AppSheet API from Google Apps Script

Hi Community,

I am trying to call the AppSheet API from a Google Apps Script, but I am getting an error.

This is the code in my Google Apps Script:

function testApi(){
let appId = "1234";
var url = `https://api.appsheet.com/api/v2/apps/${appId}/tables/transactions/Action`;
var options = {
"method": "post",
"headers": {
"applicationAccessKey": "abcd"
},
"muteHttpExceptions": false,
"payload": {
"Action": "Find",
"Properties": {
"Locale": "en-US",
"Location": "34.850042, -80.7325279",
"Timezone": "Estearn Standard Time",
"UserSettings": {
"Option 1": "value1",
"Option 2": "value2"
}
},
"Rows": []
}
};
// options = {muteHttpExceptions: true};
var response = UrlFetchApp.fetch(url, options);
console.log(response.getResponseCode())
}

This is the error I receive:

Audit Log Details
Action Details
Email Details
REST API:
{
"Action": "Find",
"Properties": {},
"Rows": []
}

Properties:
{
"RestAPIVersion": 2,
"TableName": "transactions",
"AppTemplateVersion": "1.000022",
"Action": "Find",
"Errors": "API 'Properties' does not have unexpected Type of 'JObject'. Value is: '{\r\n \"Action\": \"Find\",\r\n \"Properties\": \"{Location=34.850042, -80.7325279, Locale=en-US, Timezone=Estearn Standard Time, UserSettings={Option 1=value1, Option 2=value2}}\",\r\n \"Rows\": \"[Ljava.lang.Object;@75b5622e\"\r\n}'",
"AppTemplateName": "483b1d1f-de86-4005-be86-1c86584ce72c",
"Operation": "REST API invoke",
"RecordType": "Start",
"Result": "Failure"
}

I am grateful for any help on this issue.

0 13 1,501
13 REPLIES 13
Top Labels in this Space