Hello all,
I am working to create a Webhook for a Hosted Feature Service in ArcGIS Online that will use Microsoft Power Automate to send emails when a HTTP request is received. I want to receive emails when a feature service is edited, but I am having trouble with my payload schema for the HTTP request (receiving a "BadRequest" error). I am wondering if anyone has done this and can share what their JSON payload schema consisted of.
Thanks,
Henry
Hi Henry Pelesh, there are some example payloads shown on this blog: Create a hosted feature service webhook
Hope this helps,
-Peter
Thank you for reaching out. I have gone through the blog post and have been using the example payloads given. My Webhook is looking for when Features are created, so I used the example payload below.
Using this payload schema is still giving me a "BadRequest" error in Microsoft power automate when testing my Flow.
Thanks,
Henry
Thanks Henry Pelesh - when I test my flow to generate schema it returns a few more properties, then returns the payload within the formdata property. Are you able to test the flow to generate schema or try the syntax that I've pasted below?
{
"$content-type": "application/x-www-form-urlencoded; charset=utf-8",
"$content": "cGF5bG9hZD1beyJuYW1lIjoiUGV0ZXIgVGVzdCBTZXB0ZW1iZXIgV2ViaG9vayIsImxheWVySWQiOjAsIm9yZ0lkIjoiV2w3WTFtOTJQYmp0SnM1biIsInNlcnZpY2VOYW1lIjoiV2ViaG9va19GZWF0dXJlX0xheWVyX0RlbW8iLCJsYXN0VXBkYXRlZFRpbWUiOjE2MDAwMzIzMzcyNzIsImNoYW5nZXNVcmwiOiJodHRwcyUzYSUyZiUyZnNlcnZpY2VzLmFyY2dpcy5jb20lMmZXbDdZMW05MlBianRKczVuJTJmYXJjZ2lzJTJmcmVzdCUyZnNlcnZpY2VzJTJmV2ViaG9va19GZWF0dXJlX0xheWVyX0RlbW8lMmZGZWF0dXJlU2VydmVyJTJmZXh0cmFjdENoYW5nZXMlM2ZzZXJ2ZXJHZW5zJTNkJTViNTAzMzI3NzElMmM1MTY3Mzk3MSU1ZCUyNmFzeW5jJTNkdHJ1ZSUyNnJldHVyblVwZGF0ZXMlM2RmYWxzZSUyNnJldHVybkRlbGV0ZXMlM2RmYWxzZSUyNnJldHVybkF0dGFjaG1lbnRzJTNkZmFsc2UiLCJldmVudHMiOlsiRmVhdHVyZXNDcmVhdGVkIl19XQ==",
"$formdata": [
{
"key": "payload",
"value": "[{\"name\":\"Peter Test September Webhook\",\"layerId\":0,\"orgId\":\"<myOrgName>\",\"serviceName\":\"Webhook_Feature_Layer_Demo\",\"lastUpdatedTime\":1600032337272,\"changesUrl\":\"https://services.arcgis.com/myOrgName/arcgis/rest/services/Webhook_Feature_Layer_Demo/FeatureServer/extractChanges?serverGens=[50332771,51673971]&async=true&returnUpdates=false&returnDeletes=false&returnAttachments=false\",\"events\":[\"FeaturesCreated\"]}]"
}
]
}
I hope this helps,
-Peter
Hi Henry Pelesh,
The webhook request sent by ArcGIS Online does not appear to contain a Content-Type : application/json in the header. This is why Power Automate considers it by default as application/x-www-form-urlencoded.
1- You can use this Request Body JSON Schema for your module When a HTTP request is received or generate schema from payload sample provided by Peter Klingman :
{
"type": "object",
"properties": {
"$content-type": {
"type": "string"
},
"$content": {
"type": "string"
},
"$formdata": {
"type": "array",
"items": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"key",
"value"
]
}
}
}
}
After running a test, you should get this $formdata output :
[
{
"key": "payload",
"value": "[{\"name\":\"Power Automate\",\"layerId\":0,\"orgId\":\"<myOrgID>\",\"serviceName\":\"demoWebhook\",\"lastUpdatedTime\":1603875450774,\"changesUrl\":\"https://services.arcgis.com/<myOrgID>/ArcGIS/rest/services/demoWebhook/FeatureServer/extractChanges?serverGens=[24014837,24187488]&async=true&returnInserts=false&returnDeletes=false&returnAttachments=false\",\"events\":[\"FeaturesUpdated\"]}]"
}
]
Example :
2- To extract and parse the payload value, you can use Parse JSON module with this content as input (return the first element for the payload value in formdata) :
first(json(triggerFormDataValue('payload')))
first(json(triggerBody()?['$formdata'][0]?['value']))
json(triggerBody()?['$formdata'][0]?['value'])[0]
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"layerId": {
"type": "integer"
},
"orgId": {
"type": "string"
},
"serviceName": {
"type": "string"
},
"lastUpdatedTime": {
"type": "integer"
},
"changesUrl": {
"type": "string"
},
"events": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
Example :
After running a test, you should get this output :
{
"name": "Power Automate",
"layerId": 0,
"orgId": "<myOrgID>",
"serviceName": "demoWebhook",
"lastUpdatedTime": 1603875450774,
"changesUrl": "https://services.arcgis.com/<myOrgID>/ArcGIS/rest/services/demoWebhook/FeatureServer/extractChanges?serverGens=[24014837,24187488]&async=true&returnInserts=false&returnDeletes=false&returnAttachments=false",
"events": [
"FeaturesUpdated"
]
}
Now, you can use informations contained in the payload as dynamic content to request changesUrl, ... like this blog: Create a hosted feature service webhook
This was very helpful. Thank you.
-Henry
This is beautiful. Thank you.
Hi @hgaignard
I'm trying to follow your example, but I am having trouble running the test. I cannot do the "Automatically" test option because I do not have a recently used trigger. And when I try to test "Manually" by creating an update to the hosted feature service... nothing happens. Is there a different way to run a test in order to get the output that you are showing above? I've set up my flow similar to yours. I do not understand how you test just the "When a HTTP request is received". Even if I try to save at this point I get an error message. Any help would be much appreciated!! Thanks
Your Request Body JSON Schema appears to be incorrect. I struggled with this piece of the puzzle for quite some time! Copy the example @hgaignard gave in the first code window of his post into the Request Body window you show in your screenshot. Notice the '$content-type' key in his example.
Thank you @PhilLarkin for catching that! I pasted his sample payload directly into the request body, I had pasted it in the "generate schema" window earlier. Now to test... I selected test manually in Power Automate, then I went into AGO in a new window and created two updates to the hosted feature service (Web hook is enabled with correct hookurl). It's been several minutes and I'm still getting the spinning donut in Power Automate. Any other ideas? Thank you!