AGOL Feature Service Webhooks

9862
38
07-07-2020 02:35 AM
RonParis
Occasional Contributor

Referencing the recent blog post which has introduced webhook to hosted feature services in AGOL. I was wondering if it was possible to use this to return the updates that have been made to the feature class. 

At the moment, it will tell me when a feature has been created, but I want to be able to pull the attributes of the feature that was created.

TIA

Tags (1)
0 Kudos
38 Replies
TylerBragg2
Occasional Contributor II

Peter Klingman‌,

Thanks for the update!  I'll check this out and I'm sure I will learn a few things.  I wasn't aware of the "sleep" function in Integromat, so I'll have to look into that as well.  Awesome!

Tyler

by Anonymous User
Not applicable

Sounds good! I didn't know about the Sleep function either, was pretty excited to learn about that. 

0 Kudos
RonParis
Occasional Contributor

Hoping you can advise on this one @Anonymous User...

I've started using Integromat to automate and grab the resulting json file and give me the specific attributes I am after (referenced at the bottom of the blog post). The only issue I'm encountering is that my feature service needs to be publicly shared for this to work. Is it possible to build into the Integromat scenario an authentication so that this can be achieved without needing to publicly share an editable feature service?

0 Kudos
by Anonymous User
Not applicable

Hi @RonParis - I had to check the blog to be sure, but it is surprising that it was written for a publicly editable hosted layer. Since we are now more explicitly discouraging publicly editable layers, this would be important to amend. 

You will need to generate a token that will be appended to the URLs. You can do this in Integromat with the HTTP module. I did test this quickly and it returns a token that can be used to access a secure service. Then you would append the token to each of the service URLs to access the endpoints. Below are the parameters I used in the request body, also documented in the generateToken link. 

Peter_Klingman_1-1611189644829.png

 

Peter_Klingman_0-1611189545839.png

I hope this helps ~ it definitely needs some fine-tuning but I hope this gets you started!

-Peter 

 

RonParis
Occasional Contributor

That's great, thanks @Anonymous User. I've managed to get the token to generate and then append to the URLs along the scenario, utilising the substring function to grab the token from HTTP response. It's not the prettiest but it works!

by Anonymous User
Not applicable

Glad it worked!

0 Kudos
MennoTerBals_GIS4C
Esri Contributor

@Anonymous User  @RonParis Thanks for this information! I'm trying the same thing, the token is generated, I appended it to the changesUrl, which works, but when I append it to the statusUrl the output gives me an error:

The length of the URL for this request exceeds the configured maxUrlLength value.

Any ideas how to solve this?

0 Kudos
RonParis
Occasional Contributor

@MennoTerBals_GIS4C if you're not using the substring function to grab the token, try this

 

MennoTerBals_GIS4C
Esri Contributor

@RonParisThanks for the advice. I did use the substring function but instead of using "/0?token=" I used "&token=". This works in the HTTP request to the changesUrl, but not in the HTTP request to the statusUrl or the resultUrl. So now it looks like this and it works:

changesUrl.PNGstatusUrl.PNGresultUrl.PNG

Thanks. Menno


0 Kudos
by Anonymous User
Not applicable

Hi @RonParis and @MennoTerBals_GIS4C I've been taking a much closer look at webhooks in preparation for a dev summit tech session (shameless plug, definitely check it out if you're planning to attend). I left out earlier the importance of the JSON module in Integromat. You shouldn't need to use the substring function; instead, choose the Parse JSON option from the JSON module and parse the JSON response of generate token to obtain the token. 

In working with some colleagues as well (my apologies for not having as much awareness of this a few weeks back) we are really recommending the use of Integromat's HTTP module to make an Oauth2 request both for secure resources obtained with a GET request and to generate a server token that can be reused in post requests. Follow these steps to get started. You will need to register an app in ArcGIS Online with the redirect URI that Integromat specifies, too. 

Here are some sample screenshots of how my Oauth2 request module is set up:

Peter_Klingman_0-1612573276305.png

Peter_Klingman_1-1612573331368.png

You'll also input your app's client ID and client secret when setting up the module, but these are hidden after configuration. 

I hope this helps,

-Peter