我尝试将发布请求发送到外部服务器。但是我总是遇到500错误。我在Postman中使用此URL和JSON对象进行了测试,并且可以正常工作。
https://demo.overconline.com/api/opportunities的请求失败,返回了代码500。服务器响应被截断:{“ message”:“ error.internalServerError”,“ description”:“内部服务器错误”,“ fieldErrors”:null}(使用MutetHttpExceptions选项检查完整的响应)(第178行,文件“代码”)
function createdOpportunity(){
var auth = getToken();
var data = {
"createdBy": "first-admin",
"sequenceNumber": "",
"indexKeyValue": "opportunity name",
"stageId": "5b680dbcb5557900013686b8",
"assignee": "None",
"stageHistory": [
{
"stageId": "5b680dbcb5557900013686b8",
"stageHistoryRecords": [
{
"addedDate": null,
"removedDate": ""
}
]
}
],
"order": [],
"permissionType": 2
};
Logger.log(data);
Logger.log(JSON.stringify(data));
var webAppUrl="https://demo.overconline.com/api/opportunities";
var header = {'contentType':'application/json','Authorization': 'Bearer '+ auth };
var options = { 'method':'POST','headers':header ,'payload':JSON.stringify(data)};
var response = UrlFetchApp.fetch(webAppUrl, options);
var result = JSON.parse(response.getContentText());
Logger.log(result);
Logger.log('Permission type '+response);
return result;
}