【发布时间】:2017-12-30 02:00:47
【问题描述】:
您好,我在 Google 应用程序脚本中找不到此错误。我审查了我的代码很多时间,但什么也没有。此代码用于与入站营销一起使用的服务中的 webhook,我有一些弹出表单来获取我的时事通讯的用户,我希望这个订阅者到我的 Mail chimp 帐户只是为了发送有关博客的更新。所以我使用下面的代码来做这件事,但我收到了这个错误。对不起,如果我编码错误。 JSON源是这样的https://github.com/ResultadosDigitais/rdocs/blob/master/rdstation_integration.json 我创建的 md5Hash 函数用于给出字符串的哈希值。
如果有人可以帮助我,非常感谢!
//receive the request
function doPost(e){
return mcResponse(e);
}
//Send information to MC
function mcResponse(n){
var email = n.parameter["leads[email]"];
var nome = n.parameter["leads[name]"];
var hash = md5Hash(email);
try {
var bodyData = [];
var mergeFields = ["FNAME" = nome];
bodyData.push([
"email_address" = email,
"status_if_new" = "subscribed",
"status" = "subscribed",
"merge_fields" = mergeFields
]);
var headers = {
'Content-type': 'application/json',
'Authorization': 'apikey ' + API_KEY_MC
};
var options = {
'method': 'PUT',
'headers': JSON.stringify(headers),
'payload': JSON.stringify(bodyData)
};
var response = UrlFetchApp.fetch(MC_URL + LIST_ID + '/members/' + hash, options);
return ContentService.createTextOutput(response.getContentText());
} catch(e){
return ContentService.createTextOutput(e);
}
}
【问题讨论】:
-
也许我错过了,但我无法在此处找到错误的详细信息。你能提供吗?
-
请阅读故障排除指南:Link to Apps Script documentation
标签: javascript google-apps-script