在使用来自谷歌应用脚本的freshdesk api时出现错误
"{"code":"invalid_content_type","message":"Content-Type header is set to . It should be set to application/json"}"
用于此的代码
function hd_getTickets(){//using v2
var API_KEY = 'xxxxxxxxxxxxxx';
var headers = {'Content-type': 'application/json','Authorization': 'Basic ' + Utilities.base64Encode(API_KEY + ':X') };
var data = { "query":"\"priority:3\"" };
var ENDPOINT = 'https://xxxxxxx.freshdesk.com/api/v2';
var url = ENDPOINT + '/search/tickets';
var options = { 'method': 'get', muteHttpExceptions: true,'headers': headers,'payload' : JSON.stringify(data)};
var response = UrlFetchApp.fetch(url, options);
}
更改端点并从选项中删除有效负载,因此假设授权和标头很好
var url = ENDPOINT + '/tickets';
var options = {'method':'get','headers':headers, muteHttpExceptions: true};
使用邮递员这工作
https://xxxxxxx.freshdesk.com/api/v2/search/tickets?query="priority:3"
标头设置为
Content-Type:application/json
Authorization:Basic xxxxxxxxxxxxxxxx