Payload sturcture in automation calling a webhook

Iโ€™m created a custom tasak under Automation to call a webhook which the webhook is created using Google Apps Script publish as web app. Iโ€™m able to get the event object from AppSheet but the payload part which i defined with a body template seems odd when received.

Under [contents] there seems to be extra double quotes โ€œ{}โ€ which is causing trouble when i try to get the objects inside. Are the double quotes โ€œ{}โ€ intended for the payload POST or am I doing anything wrong?

{โ€œpostDataโ€:{โ€œcontentsโ€:"{ โ€œUpdateModeโ€: โ€œโ€, โ€œApplicationโ€: โ€œ่ซ‹ๅ‡็ณป็ตฑโ€, โ€œTableNameโ€: โ€œGoogle Sheetsโ€, โ€œUserNameโ€: โ€œโ€, โ€œAtโ€: โ€œ2021/5/20 ไธ‹ๅˆ 01:20:40โ€ , โ€œDataโ€: { โ€œapplicantโ€: โ€œxyz@gmail.comโ€, โ€œleavecategoryโ€: โ€œannual leaveโ€, โ€œnoteโ€: โ€œApplied in portalโ€, โ€œstartdateโ€: โ€œ2020/7/1โ€, โ€œstartperiodโ€: โ€œไธŠๅˆ 09:00:00โ€, โ€œenddateโ€: โ€œ2020/7/1โ€, โ€œendperiodโ€: โ€œไธ‹ๅˆ 06:00:00โ€, โ€œagentโ€: โ€œGCP teamโ€ } }",โ€œlengthโ€:378,โ€œnameโ€:โ€œpostDataโ€,โ€œtypeโ€:โ€œapplication/jsonโ€},โ€œparametersโ€:{},โ€œparameterโ€:{},โ€œcontextPathโ€:"",โ€œqueryStringโ€:"",โ€œcontentLengthโ€:378}

0 13 408
13 REPLIES 13

Yah I would say those extra quotes should not be there.

Anyone from the AppSheet team can confirm this? I customized the payload based on the given body template.

Maybe if you showed this, someone could help?

Here it is, fairly straight forward based on the template.

{
โ€œapplicantโ€:"<<[applicant]>>",
โ€œleavecategoryโ€:"<<[leavecategory]>>",
โ€œnoteโ€:"<<[note]>>",
โ€œstartdateโ€:"<<[startdate]>>",
โ€œstartperiodโ€:"<<[startperiod]>>",
โ€œenddateโ€:"<<[enddate]>>",
โ€œendperiodโ€:"<<[endperiod]>>",
โ€œagentโ€:"<<[agent]>>",
โ€œsubmissiondateโ€:"<<[submissiondate]>>",
โ€œrowโ€:"<<[_RowNumber]>>"
}

Can you show a screenshot of the entire Task definition?

No problem, here you go:

Can you actually have both a Body and a Body Template?

I donโ€™t think so - the template takes precedence, I believe. The UX should prevent the user from being able to specify both but it doesnโ€™t.

I tried with only the body and the outcome is still the same.

Are you updating another AppSheet data source with the web hook call ?

If so, what is the reason you are using a webhook instead of a data action ?

Hi @Dan_Bahir ,

No, I am triggering another process to run in Google Apps Script so i need to pass the data over. May I know if the structure above is intended ?

@Jin_Sheng_Khoo The Extra double quotes you see in the payload - is supposed to be there.

The posted payload is received as text, you can parse the received payload using JSON.parse

You can get the JSON as object by doing this - JSON.parse(JSON.stringify(e.postData.contents)) in AppsScript

@Sid , that works !

var test = JSON.parse(JSON.stringify(e.postData.contents));

{โ€œapplicant":"xyz@gmail.comโ€,โ€œleavecategoryโ€:โ€œannual leaveโ€,โ€œnoteโ€:โ€œjklโ€,โ€œstartdateโ€:โ€œ01/08/2020โ€,โ€œstartperiodโ€:โ€œ0.375โ€,โ€œenddateโ€:โ€œ01/09/2020โ€,โ€œendperiodโ€:โ€œ0.5โ€,โ€œagentโ€:"",โ€œrowโ€:โ€œ2โ€}

say if i got the above as the result, can I directly get the content by doing the following?
test.applicant

Iโ€™m trying to confirm if this is the right way because i am getting undefined as the result.

Top Labels in this Space