添加到 iAuditor 响应集(请求有效负载 JSON 格式无效)

时间:2021-02-23 01:27:45

标签: javascript json google-apps-script post urlfetch

使用 https://developer.safetyculture.io/?shell#add-a-response

我有以下几点:

function addResponse(){

 var url = 'https://api.safetyculture.io/response_sets/responseset_id/responses';
 var myBody =  {"label": "String To Add"};
 var headers = {"Authorization" : 'Bearer ' + 'api_key'};
 var params = {
   'method': 'POST',
   //'muteHttpExceptions': true,
   'headers': headers,
   'contentType': 'application/json',
   'payload': myBody
 };

UrlFetchApp.fetch(url, params);

}

我能够获得响应集 (https://developer.safetyculture.io/?shell#get-a-global-response-set),因此我知道 URL、Responseset_ID 和密钥是正确的。

Bad Request","message":"Invalid request payload JSON format"

我应该如何正确格式化 myBody

0 个答案:

没有答案