In order to create the reports, one of the required parameters is the token generated during the login session.
To generate the token, I’m using the “@esri/arcgis-rest-auth” module.
Another way that I tried for generating the token is through the ArcGIS REST API POST request with the “generateToken” method with the following specifications:
With both token generating methods I get the same error when requesting a report. “Error: Could not generate report! An error occurred when rendering by the report engine. Failed to print map. Error: Failed to load feature layer: Invalid token.”
Is there another way for generating a valid token? Is the error related to the current token generated or is the error related to something else?
That error seems like the report API is trying to generate the report and failing on generation maybe not so much on the initial API call. If you try running the report directly from the Survey123 web UI is the same error returned or does the report generate successfully there?
If the report generates successfully from the Survey123 web UI try setting the referer to https://www.arcgis.com.
I already tried setting the referer to https://www.arcgis.com when generating the token through the ArcGIS REST API POST request. I get the same error with that referer.
Did you find a solution? I'm facing the same issue.
When I grab the token from the UI using Chrome' dev tools I'm able to produce a report using the API.
When I use a token generated by an ArcGIS API for python I can also produce a report.
But the token generated by https://www.arcgis.com/sharing/generateToken is failing.
The workaround was to retrieve the token after entering the credentials for the login process. If the credentials are accepted, the access token is returned as part of the URL fragment appended to the redirect_uri (See https://developers.arcgis.com/rest/users-groups-and-items/authentication.htm for more details.)
I was developing in nuxt.js, so in order to get the url string during the login…
const tokenUrl = this.$route.fullPath
And to retrieve the token…
const parsedTokenUrl = tokenUrl.split('#')
const lstTokenUrlParams = parsedTokenUrl.split('&')
const token = lstTokenUrlParams.split('access_token=')
Hope this helps.