Question workflow sending JSON data to Google appscript

DaveR
New Member

I Currently have an app that is not deployed, so I know that workflows are not triggered.
But they can still be tested, right? They should still send data when โ€œtestedโ€ as described below?

I am developing a workflow that sends a JSON payload to an appscript (a stand alone web app), whose function (at the moment) is solely to show me the JSON object in an email.

So if I โ€œtestโ€ a workflow, I get a page with all the possible results (the data I expect shows up - example at the end). I can โ€œsendโ€ one example and it indeed makes the appscript do its job and I receive an email. (so the appscript URL is correct).
(I use email to report the results as the โ€œLoggerโ€ function appears to not record anything from a stand alone web app.)

In the workflow, I have the โ€œverbโ€ set to โ€œPostโ€ and โ€œHTTP contentโ€ set to โ€œJSONโ€
There are no headers and the body template is (for all practical purposes I let Appsheet generate it)
{
โ€œEventโ€: โ€œ<<[Event]>>โ€,
โ€œStart Dateโ€: โ€œ<<[Start Date]>>โ€,
โ€œEnd Dateโ€: โ€œ<<[End Date]>>โ€,
โ€œsitter addressโ€: โ€œ<<[sitter address]>>โ€,
โ€œemail listโ€: โ€œ<<[email list]>>โ€,
โ€œDogโ€: โ€œ<<[Dog]>>โ€,
โ€œSitterโ€: โ€œ<<[Sitter]>>โ€,
}

my appscript is

function doPost(e) {
var data = e.parameter

MailApp.sendEmail({
to: โ€œmyemailโ€,
subject: โ€œresults logโ€,
htmlBody: โ€œlog eventsโ€ + data + e.parameter })
}
and the body of the resulting email is
log events [object][object][object][object]

Essentially a blank set of data. Does not โ€œeโ€ contain the object?
if not, how do I obtain the JSON object so that I can parse the data sent to the appscript.
If this is not a valid method to test the workflow - is there a way without deploying itโ€ฆ yet.


an example of the โ€œRule Actionโ€ from the โ€œtest pageโ€ with PII removed.
{
โ€œ$typeโ€: โ€œNirvana.Data.WorkflowActionResultWebhook, V2APIโ€,
โ€œHeadersโ€: {
โ€œ$typeโ€: โ€œSystem.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.String, mscorlib]], mscorlibโ€
},
โ€œPayloadโ€: โ€œ{โ€œEventโ€: โ€œHonor Sits with Leitchโ€,โ€œStart Dateโ€: โ€œ4/16/2019โ€,โ€œEnd Dateโ€: โ€œ4/20/2019โ€,โ€œsitter addressโ€: โ€œ414 XXXXXXXXXX3, USAโ€,โ€œemail listโ€: โ€œemail1 , email2โ€,โ€œDogโ€: โ€œ1016โ€,โ€œSitterโ€: โ€œ1018โ€,}โ€,
โ€œUrlโ€: โ€œhttps://script.google.com/macros/s/AKfycbyPQFC6A_jcvPOXIrEvi7OIPHZ6vP0shIkQKWze6Op1kUvXmWTs/execโ€,
โ€œVerbโ€: โ€œPostโ€,
โ€œMimeTypeโ€: โ€œapplication/jsonโ€,
โ€œTimeoutSecondsโ€: 180,
โ€œMaxRetryCountโ€: 3,
โ€œAsyncExecโ€: false
}

0 2 979
2 REPLIES 2

@DaveR, you need to use e.postData.contents rather than e.parameter. See this - https://developers.google.com/apps-script/guides/web

DaveR
New Member

Yeah. OK - that is where I started, because it made more sense, but it would not even run.
Obviously, I had another issue(s) that caused it to failโ€ฆ
Thank you for your prompt reply!!

Top Labels in this Space