如何通过Google脚本进行iContact API调用 [英] How to make iContact API call from Google scripts
问题描述
我需要在Google脚本中编写一个通过API将联系人添加到icontact的函数.我有以下代码可用于更改联系人,但我无法更改代码以添加联系人...没有人知道如何编写呼叫来添加联系人吗?
I need to write a function in google scripts that addes a contact to icontact via API. I have the following code which works to change a contact but I am unsuccessful in changing the code to add a contact... Does anybody know how to write the call to add a contact?
function sendHttpPost() {
var headers= {
"API-Username":"XXXXX",
"API-AppId":"XXXXXX",
"API-Version":"2.0",
"API-Password":"XXXXX",
"Accept":"application/json"};
var payload =
{
"contactId":1976438,
"email":"schnick@schnack.com",
"prefix":"Mr.",
"firstName":"X",
"lastName":"XXXXX",
};
var options =
{
"headers" : headers,
"method" : "post",
"payload" : payload
};
UrlFetchApp.fetch("https://app.icontact.com/icp/a/XXXXX/c/XXXX/contacts/1976438", options);
}
推荐答案
根据发布的文档位于您Post
访问的URL中.要更新联系人,URL路径以{contactId}
结尾,而要添加联系人,则将其省略.
The difference between an update and an add, according to the posted documentation, is in the URL you Post
to. To update a contact, the URL path ends with the {contactId}
, while to add a contact you leave that out.
添加:
https://app.sandbox.icontact.com/icp/a/{accountId}/c/{clientfolderId}/contacts/
更新
https://app.sandbox.icontact.com/icp/a/{accountId}/c/{clientfolderId}/contacts/{contactId}
在上面的代码中,您包括{contactId}
,"1976438".删除该链接,您将添加一个新联系人.
In your code above, you're including {contactId}
, "1976438". Drop that, and you'll be adding a new contact.
这篇关于如何通过Google脚本进行iContact API调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!