我正在尝试使用Google Apps脚本访问Salesforce的Bulk API 2.0和upload the CSV data to a job,但是Salesfore返回了
pip install psycogreen
基于我对Salesforce API的经验,我高度怀疑问题实际上与方法类型有关,但是还有其他一些验证会导致此错误。但是,在检查请求正文并将其与我成功通过cURL提交的内容进行比较之后,我看不到我可以解决的方法。
请求代码:
[{"errorCode":"METHOD_NOT_ALLOWED","message":"HTTP Method 'GET' not allowed. Allowed are PUT"}]
通过getRequest()
返回的Google Apps脚本请求:
var headers = {
"Authorization": "Bearer TOKEN"
};
var options = {
"method": "put",
"contentType": "text/csv",
"headers": headers,
"payload": "Id,Entity_Name__c\n001,One\n002,Two\n003,Three"
};
var url = INSTANCE + "/services/data/v44.0/jobs/ingest/" + JOB_ID + "/batches";
UrlFetchApp.fetch(url, options);
cURL请求:
{
"headers": {
"Authorization": "Bearer TOKEN"
},
"method": "put",
"payload": "Id,Entity_Name__c\n001,One\n002,Two\n003,Three",
"followRedirects": true,
"validateHttpsCertificates": true,
"useIntranet": false,
"contentType": "text/csv",
"url": "INSTANCE/services/data/v44.0/jobs/ingest/JOB_ID/batches"
}
我该如何解决?