调用Google Apps Script Web App时出现400错误求助
Google Apps Script Web App 接收Thrive Automator请求时400错误排查
问题概述
开发并部署了一个简单的Google Apps Script Web App,部署设置为「以我身份执行」且所有人可访问。但通过WordPress的Thrive Automator调用时,触发400错误,提示:400. That’s an error. Your client has issued a malformed or illegal request. That’s all we know.。未找到GAS Web App接收数据格式的官方文档来规避该错误。
现有Web App代码
function doPost(e) { try { Logger.log('Data received : ' + JSON.stringify(e)); return ContentService.createTextOutput(JSON.stringify({status: 'success'})).setMimeType(ContentService.MimeType.JSON); } catch (error) { Logger.log('Error: ' + error.message); return ContentService.createTextOutput(JSON.stringify({status: 'error', message: error.message})).setMimeType(ContentService.MimeType.JSON); } } function doGet(e) { return ContentService.createTextOutput("Only POST request accepted."); }
请求数据对比
Postman调用成功时的请求数据
{ "contentLength": 0, "parameters": { "email": [ "john_doe@fakemail.com" ], "progression": [ "50" ], "id_formation": [ "5" ] }, "contextPath": "", "parameter": { "email": "john_doe@fakemail.com", "progression": "50", "id_formation": "5" }, "queryString": "email=john_doe@fakemail.com&progression=50&id_formation=5" }
Thrive Automator调用失败时的请求数据(异常部分:{"postData":{"contents":"{\"\":\"\"}","length":7,"name":"postData","type":"application/json"})
{ "postData": { "contents": "{\"\":\"\"}", "length": 7, "name": "postData", "type": "application/json" }, "contextPath": "", "parameters": { "progression": [ "50" ], "email": [ "john_doe@fakemail.com" ], "id_formation": [ "5" ] }, "parameter": { "email": "john_doe@fakemail.com", "id_formation": "5", "progression": "50" }, "contentLength": 7, "queryString": "email=john_doe@fakemail.com&progression=50&id_formation=5" }
Thrive Automator团队回复
Kenneth于11月6日5:24回复:
您好Florent,
我接替Kurt为您服务,他目前不在。
我在Thrive Automator中测试了您提供的Web App URL,仍出现400错误。
Thrive Automator可向webhook.site、邮件营销平台等其他平台发送webhook,我在webhook.site测试时能正常收到JSON数据。
看起来格式错误的字段"contents":"{\"\":\"\"}"是由于您的Google App Script处理请求的方式导致的。
我们无法为您创建的Google App Script提供支持,这属于深度自定义内容,超出了我们的支持范围。
能否告知您使用该Google App Script的用途,以便我们提供替代方案?我们或许能帮您找到其他解决办法,但无法修复您的Google App Script。
期待您的回复。
内容的提问来源于stack exchange,提问作者Florent
相关产品推荐
相关产品推荐

