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 975
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