Webhook Template not picking up child records

MikeZ
New Member

Hi,
I have a Workflow Action to a webhook to POST to a Rest API. The json data is a parent/child. The UX interface and the underlying data entered into Google Sheets is fine. However, the webhook template is not passing any child records. Any troubleshooting hints? I deleted and recreated the workflow. I authenticate fine, and I use webhooks with the same REST API in another appsheet app, though that template doesn’t rely on the START construct.
Here’s the template that’s failing to catch child records

The child data is “Transfer Lines”

{
   "purpose": "Material Transfer",
   "name": "<<[ID]>>",
   "company": "#######",
   "posting_date": "<<[Date]>>",
   "owner": "<<[User]>>",
   "from_warehouse": "<<[From Warehouse]>>",
   "to_warehouse": "<<[To Warehouse]>>",
   "items": [
      <<Start: [Related Transfer Lines]>>
      {
         "s_warehouse":"<<[s_warehouse]>>",
         "t_warehouse":"<<[t_warehouse]>>",
         "item_code": "<<[Item Code]>>",
         "qty": "<<[Quantity]>>",
         "transfer_qty": "<<[Quantity]>>",
         "uom": "Each",
         "stock_uom": "Each",
         "conversion_factor": 1
      },
      <<End>>
   ]
}

I must be missing something
Mike

1 9 423
9 REPLIES 9

I don’t see anything syntactically wrong with the JSON or templated variables. I would double check the parameter names for the REST API on the server side to make sure all or spelled exactly correct.

Also, REST services could implement required fields and will error if they are not included.

Have you looked at the AppSheet log to see if any issues are reported there? Are there any logs on the REST service side you can view?

There are many REST API tools that will allow you to paste in the JSON and test the API call, getting immediate feedback of any errors. This will at least allow you to test the syntax is correct and expected required fields are included.

Postman API Client is one I have used. It is free.

MikeZ
New Member

Thanks, John, for looking. I did “hide” a couple of columns before it stopped working so maybe the workflow bugs out if it doesn’t see them? The columns that were hidden do show in the log of the API call. The server just throws a 4xx code because it needs the line items to make the record. I’ll keep poking around, at least I know the template’s good.

And, yes, I do use Postman. It’s even a decent json validator.

Mike

As @WillowMobileSystems suggested, check the logs to see if there are any errors, as well as the see the exact data that is sent through.


Maybe try to remove this comma right here? I believe START expressions in some instances insert their own commas between iterations.

MikeZ
New Member

Thanks for the ideas, tried them all now, with no luck. It seems that when I remove the REF child field from the template, which I do not need for the webhook, the child lines don’t get generated. So it seems that Appsheet uses the webhook body template to validate the data?

So what did the logs look like? What was the full payload that was being sent?

When I excluded the child REF from the template, the payload had the header for the child records, then empty
When I put the child REF column back in the template, I got a payload with a valid child record.
Here’s the payload with the missing child data:

“Payload”: “{“name”: “QT-3da51718”,“posting_date”: “11/20/2020”,“modified_by”: “mike@ssbsinc.com”,“From Warehouse”: “From Warehouse1”,“To Warehouse”: “To Warehouse1”,“items”: }”,

And here’s with the REF column, labelled “parent” included:
“Payload”: “{“name”: “QT-3da51718”,“posting_date”: “11/20/2020”,“modified_by”: “mike@ssbsinc.com”,“From Warehouse”: “From Warehouse1”,“To Warehouse”: “To Warehouse1”,“items”: [{“parent”: “QT-3da51718”,“line_id”: “52e57218”,“code”: “12”,“item_code”: “12345”,“qty”: “2”}]}”,

Can you try to construct the child records as a VC? Of course it might slow down the sync but it might get you what you want.

That could work, but I think i solved it by ensuring the REF column is included in the template for the child records. I had to figure out where to “put it” on the server application side, but that worked out as well. Thanks for all the ideas!

Mike

MikeZ
New Member

Ok, it seems that an invalid body template must be cached.
The most recent template is referenced in the workflow action, and it looks fine when I view it. However, the payload in the log entry is totally different, obviously from a prior version.
And here’s a kicker. If I run the workflow in “Test”, the correct , valid payload is displayed and the webhook works as expected.
So I’m going to log out of the dev site, close browser, flush cache, delete old templates from Google Drive and go have a cup of tea.

Mike

Top Labels in this Space