Select to view content in your preferred language

Is there a way to submit survey responses via rest/python and keep the Microsoft power automate functionality?

494
2
09-01-2020 05:54 AM
CA_-_MattWingard__GISS_
New Contributor

Long story short, but when I add features to my survey feature service (using the python arcgis api or via rest) it seems like the webhooks that interface with my Microsoft Power Automate do not work like they do when a "traditional" survey is submitted. Is there a way around this? Is it possible to mimic a traditional survey response via rest/python and maintain the power automate functionality?

Would be great if power automate could work directly on feature service adds/updates. 

2 Replies
Ruth_JiatengXu
Esri Contributor

Hello Matt,

You are correct, the add/updates on the feature service will not trigger the webhook because the webhook payload is sent by the "traditional" survey.

Although this is not a recommended practice, you can send the payload to your webhook with additional code. First, get your payload URL in the settings page -> webhooks tab, and then set up a POST request with the survey payload, and send the request to the payload URL.

Could you please share your use case with us, so we can help you better?

Thanks,

Ruth

0 Kudos
Raquel
by
New Contributor

I'm trying to automate a flow with python and I can't get the record to be inserted in my survey123, while I do activate the webhook, because it sends the mail, but without the information of the record, because, as I said, it doesn't insert the row.

Could you tell me how to do it so that it inserts the row and in the message appears the information of that record?

survey_seguimiento_url = 'https://services5.arcgis.com/..../FeatureServer/0/applyEdits'

survey_payload = {
'features': [{
'attributes': {
'Name': 'NAME AUTO',
'Email': 'xxxx',
}
}]
}

response = requests.post(survey_seguimiento_url, json=survey_payload)

if response.status_code == 200:
print('Survey123 inserted')
else:
print(f'Error: {response.status_code}')
print(response.text)
exit()


power_automate_webhook_url = 'https://prod-169.westeurope.logic.azure.com/workflows/....M'

webhook_payload = {

'Name': 'Raquel AUTO',
'Email': 'xxxx',

}


response = requests.post(power_automate_webhook_url, json=webhook_payload)


if response.status_code == 200:
print('Request successfully sent to Power Automate')
elif response.status_code == 202:
print('Request accepted for processing by Power Automate')
else:
print(f'Error sending the request to Power Automate: {response.status_code}')
print(response.text)


Thank you very much!

0 Kudos