ArcGIS Online Webhook on FeaturesCreated if content is set to application/json the changesUrl comes in partially encoded

671
2
Jump to solution
04-17-2021 07:29 AM
Labels (1)
CarlVricella1
New Contributor

Hi all,

I have a webhook set up on a Hosted Feature Layer and for some reason the changesUrl is coming in partially encoded, for example:

        "changesUrl": "https%3a%2f%2fservices2.arcgis.com%2fO48sbyo4drQXsscH%2fArcGIS%2frest%2fservices%2fFinn_Maps_HFS%2fFeatureServer%2fextractChanges%3fserverGens%3d%5b479297%2c479305%5d%26async%3dtrue%26returnUpdates%3dfalse%26returnDeletes%3dfalse%26returnAttachments%3dfalse"

 

I have a WSGI server set up (using bottle) that is the hook url so I have the entirety of python at my disposal. Outside of trying to pull out the needed information and programmatically recreating the URL...which will probably be error prone is there any other way to fix this? I tried looking on some forums to see if it was possible to decode an 'encoded' string ( I mean it's encoded, but not 'encoded' by python so the decode method won't be available) and it doesn't seem to be or at least it's not common. 

I'm guessing if I use url form encoded content type I probably won't have this issue because I set up a scenario on integromat and this was no problem. Issue here is that I have my route set up application/json already and don't really want to change that if I don't have to

Any suggestions? Thanks!

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JeffreyHolycross
Esri Contributor

Re-creating this post:

The URL is indeed encoded, but maybe not in the way you're thinking if you're trying to use 'decode' methods. This format is known as an encoded URL (see https://www.w3schools.com/html/html_urlencode.asp).  I can't say if the changesUrl should be encoded, but I agree that the webhook payload includes an encoded URL.

In Python, you can translate a URL-encoded string to a non-encoded URL via urllib.parse.unquote (https://docs.python.org/3/library/urllib.parse.html).

EDIT: Carl pointed out that the requests library has similar functionality: requests.utils.unquote(url)

View solution in original post

2 Replies
CarlVricella1
New Contributor

Awesome that is exactly what I was looking for, thank you

 

edit: In-case anyone is interested, there is also a requests module equivalent: requests.utils.unquote(url)

JeffreyHolycross
Esri Contributor

Re-creating this post:

The URL is indeed encoded, but maybe not in the way you're thinking if you're trying to use 'decode' methods. This format is known as an encoded URL (see https://www.w3schools.com/html/html_urlencode.asp).  I can't say if the changesUrl should be encoded, but I agree that the webhook payload includes an encoded URL.

In Python, you can translate a URL-encoded string to a non-encoded URL via urllib.parse.unquote (https://docs.python.org/3/library/urllib.parse.html).

EDIT: Carl pointed out that the requests library has similar functionality: requests.utils.unquote(url)

View solution in original post