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}
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.
User | Count |
---|---|
15 | |
14 | |
8 | |
7 | |
4 |