我试图像这样在doPOST(e)中获取JSON对象:
{
"leads": {
"status": {
"id": "25399013",
"name": "Lead title",
"old_status_id": "7039101",
"status_id": "142",
...
,然后在doPOST(e)中使用它:e.parameters.leads.status ...
但是我得到这样的东西:
{"parameter":{"leads[status][0][responsible_user_id]":"423726","account[_links][self]":"https://tfkk.amocrm.ru","leads[status][0][date_create]":"1554445774","leads[status][0][custom_fields][1][id]":"623735","account[subdomain]":"tfkk","leads[status][0][modified_user_id]":"423726"
在doPOST(e)e.postData.contents中包含:
leads%5Bstatus%5D%5B0%5D%5Bid%5D%3D23419547%26leads%5Bstatus%5D%5B0%5D%5Bname%5D%3DName+Lead%26leads%5Bstatus%5D%5B0%5D%5Bstatus_id%5D%3D24851404%26leads%5Bstatus%5D%5B0%5D%5Bold_status_id%5D%3D22645123
或
leads[status][0][id]=23419547&leads[status][0][name]=Name Lead&leads[status][0][status_id]=24851404&leads[status][0][old_status_id]=22645123
手动调用JSON.parse(e.postData.contents)
会导致错误:
SyntaxError:意外令牌:l在测试(代码:11)。
尽管任何webhook联机服务都会根据相同的帖子数据文本提供正确的JSON
。如何在JSON
中获得正确的doPOST()
对象?