Survey123 Rest API: How to use authentication token to generateReport?

324
2
08-18-2021 08:07 AM
JoseVidal
New Contributor III

I'm trying to use the arcgis API to write a script that calls the GenerateReport REST API. The first step is to authenticate, and I am stuck there.

I first get the token with:

curl --location -g --request POST 'https://www.arcgis.com/sharing/rest/oauth2/token?
grant_type=client_credentials&
client_id=MYAPPID&
client_secret=MYAPPSECRET'

and that works, it returns:

{"access_token":"_J3J_S_6kgKgH9vwGx4cUGa2Vj4qC0odcoe9ZBscf8nOVRlrcizRbDJxDCPar9C6zfQyp4er3lNhl5IfGs8UV5TKLZXMKtDm9......etc",
"expires_in":7200}

But then I try to create a report with

curl --location -g --request POST 'https://survey123.arcgis.com/api/featureReport/createReport?
featureLayerUrl=https://services.arcgis.com/oEazpvC7G00gPDRM/arcgis/rest/services/service_51c9906968804a1e89fedfc4804fad3f/FeatureServer&
queryParameters={}&
templateItemId=6b17895629ce4bcb87938d0381f721f2&
token=_J3J_S_6kgKgH9vwGx4cUGa2Vj4qC0odcoe9ZBscf8nOVRlrcizRbDJxDCPar9C6zfQyp4er3lNhl5IfGs8UV5TKLZXMKtDm9......etc'

and the response in an HTML page that says that I have to login.

What am I missing?

Note that the "app" I created in order to get the MYAPPID and MYAPPSECRET were created at https://uscgeography.maps.arcgis.com/  

 

 

Tags (3)
0 Kudos
2 Replies
JoseVidal
New Contributor III

Maybe someone will answer if they see that I also tried in postman:

JoseVidal_0-1629485593692.png

 

the above works to get my token. But then I do:

 

JoseVidal_1-1629485666503.png

 

 

and it still asking me to "Sign in to your ArcGIS Survey123 account"

0 Kudos
JoseVidal
New Contributor III

I also tried login in with my useraneme+password, but the same thing happens. I can get the token, but the token does not work:

 

JoseVidal_2-1629486428184.png

 

then I try to use the token:

JoseVidal_3-1629486496150.png

 

0 Kudos