ArcGIS Rest API - Webhooks using power automate and survey123 - "Error Code: 400 Invalid Query, No where Clause Specified"

2503
8
02-27-2020 04:24 AM
ILoveMap
New Contributor III

I am trying to follow the instructions in the link below to automatically update a layer after submitting a survey in Survey123. 

 

https://resources.esri.ca/getting-technical/webhooks-microsoft-flow-and-the-arcgis-rest-api-automati...

 

I'm running into problems with the query operation using a get request. It seems like the API is not accepting my query input. I've tried with and without percent encoding but was told that power automate handles that portion (conflicting with the tutorial example). The error code returned in the body of the HTTP Get request is copied below, any insight on this would be much appreciated.

"error":{"code":400,"message":"Cannot perform query. Invalid query parameters.","details":["Unable to perform query. Please check your parameters.","No where clause specified."]}}

 

8 Replies
ToryChristensen
New Contributor III

Hi Chris,

Did you ever get this to work?

Im trying to do similar, but with this query:

For testing, I've made it simple and not used dynamic content in the query (other than my token).

For some reason, the query seems to work, but only returns metadata, i.e I only get a list of all the fields, but no data...

DavidMcClennen
New Contributor III

Hi!

I'm actually having trouble with this flow and cannot figure out what I'm doing wrong here.  maybe you can help. The flow we're trying to implement here is updating a parcels layer with from a damage assessment survey. We're using html  in the popups in the fieldworkers map to pass values automatically to the survey123 form to expedite the assessment process and mitigate data entry errors.

 

Main parcels layer (noneditable) (data) > surveyform > (power automate workflow updates 2nd parcels layer (editing enabled)

 

for the flow we only reference the 2nd parcels layer and are trying to use the HCAD number (Parcelid which is a string) to relate the submitted data to the target data. but we keep getting this error. Is it because the parcelids in the form and 2nd layers are strings? or am i missing something else?

 

We got this flow from this blog post "Webhooks, Microsoft Flow and the ArcGIS Rest API – Automating Your Web GIS
": https://lnkd.in/gU5m4V5 

0 Kudos
ToryChristensen
New Contributor III

HI David,

Im definitely not an expert with this, but some how managed to get it to work in my flow.

A few things I did with mine - I removed the '+3D', it didn't seem to do anything (at least not something I could see).

Not sure if your URI is correct, should read ...?where=HCAD_NUM= '@{triggerOutputs()?['YourDATA']}'&...

With the above, Im not sure if single quote marks are required, but they seemed to fix the issue that occurs if you are trying to pass a character (/@#$%).

Not sure if this is correct, hopefully someone that knows more comes along.

0 Kudos
PhilLarkin1
Occasional Contributor III

I was experiencing the same problem: query would return geometry but not attributes. I used the wrong parameter name for Out Fields. 

Sounds like others have had similar issues with string formatting and parameter names. Be sure to doublecheck that your parameter names are correct! API doc: https://developers.arcgis.com/rest/services-reference/enterprise/query-map-service-layer-.htm

0 Kudos
erica_poisson
Occasional Contributor III

@PhilLarkin1 @ToryChristensen 

I am running into an issue here and think it has to do with the way my data is formatted...ultimately, I get the error:

erica_tefft_2-1628782474066.png

For my query parameter, I am using a field that has data formatted in the following way - EQ1234-012

Each time I test my Flow, it gets to the Parse JSON for the query and returns this:

erica_tefft_0-1628782176148.png

You can see that the returned value is truncated before the "-012" portion of the attribute value. Because of this, there is no match/no ObjectID to return in my apply to each array. I am not sure how to format the Query to properly return the entire value. I have tried a few iterations...

  1. Recommended setup via this blog (screen capture below).
  2. Replace the +%3D+ with =
  3. Surround EQ_File_Number with single quote
  4. Surround EQ_File_Number with double quotes

Here is what my query currently looks like. 

erica_tefft_1-1628782349779.png

Any suggestions on how to resolve this issue? 

Thank you!

Erica
0 Kudos
PhilLarkin1
Occasional Contributor III

I'd start with option 2. Power Automate is going to handle html encoding for you. Check your result. Does the URI Input look correct; Is the equal sign displayed or do you still have the encoded value (%3D)?

Check URI of HTTP REST:

PhilLarkin1_2-1628783987339.png


You could also try removing the where parameter from the URI and placing it in the Query body. Here is an example of a HTTP Rest call in an Apply to each loop

PA_loop.jpg




0 Kudos
erica_poisson
Occasional Contributor III

Hi @PhilLarkin1 

So the URI rest url wasn't correct - it still contained the encoding (%3D). I replaced that with a '=' but still got the error. 

I then decided to take your advice and format the HTTP GET query using the Query body. I did not do this to my "updateFeatures" HTTP request inside of my apply to each loop. Is this where you thought I should do it? 

This is what I did, the result was the same:

erica_tefft_2-1628789735489.png

 

erica_tefft_0-1628789683769.png

 

 

Erica
0 Kudos
PhilLarkin1
Occasional Contributor III

I'm not sure where your requests should be in relation to your loop. 

I'd go to the rest endpoint to test different flavors of the where clause. Try to get a successful query there and then replicate the syntax in this GET request. This is a string so it should be wrapped in quotation marks.

string.jpg

0 Kudos