External HTTP request for GP submitJob fails to use a valid token requiring extra authentication

258
3
04-30-2024 05:40 PM
EM-wsp
by
New Contributor III

I need to run a geoprocessing service as a part of the PowerAutomate Flow triggered by the S123 submission. From S123 user info, I have a valid token. The service is working and I am able to successfully run the tool using the REST form web interface, both with GET and POST requests. However, it returns the JobFailed status from Power Automate.

I also see that if I copy and paste the GET request URL from the REST form back in a web browser, my GP job get submitted again but then fails with the same error as in PowerAutomate.
URL: https://myesriportal.com/server/rest/services/My_GP_Tools/GPServer/My_Tool/submitJob?env%3AoutSR=&en...

Error:

EMwsp_0-1714523051073.png

After digging into it, I see that while GET request just fails, POST request gets a redirect asking for an extra login, even though I have provided the valid token in the request. If I try to reach my Portal content in the Incognito window, I am able to get to the GP service level appeding the token to the url, but as soon as I click "Submit a job", it promts the login window. So it looks like the token doesn't get through to the SubmitJob function. 

As I said I need to call my GP service to be run from the PowerAutomate flow. I will appreciate all suggestions how to make it work.



0 Kudos
3 Replies
A_Wyn_Jones
Esri Contributor

Just to clarify your workflow. is it this?:

S123 submission > S123 Webhook > PowerAutomate > Geoprocessing tool 

At a initial guess, It seems like the token is invalid. If the workflow above is correct, I would assume you have to build in some logic at the PowerAutomate step to request a new token as I believe the S123 token is only valid for the device and session the token is currently being used.  

"We've boosted the Anti-Mass Spectrometer to 105 percent. Bit of a gamble, but we need the extra resolution."
0 Kudos
EM-wsp
by
New Contributor III

Thank you for your reply.

Yes, the workflow is exactly as you put it. I could test to request a new token, however my primary concern is the following.

Let's forget about the Power Automate piece.  I am logged in and able to run my GP tool with help of the REST interface in browser. So I presume that I am in a valid session for running the tool. I have a URL for my SubmitJob request. However, if I copy and paste my URL in browser with a valid token appended, the job will be submitted and then fail. So it looks like the token doesn't get through with the SubmitJob request. Or do I append it in a wrong way?

SubmitJob URL:

EMwsp_0-1714580972400.png

 

0 Kudos
EM-wsp
by
New Contributor III

I have tested to generate a new token in the flow for the Server URLs:
-  https://myesriportal.com/server
https://myesriportal.com/server/rest/services/My_GP_Tools/GPServer/My_Tool/submitJob

Both did not help.

I have also noticed that if I don't append any token  to the SubmitJob URL, my job does not get submitted returning Error 499 "Token required". It means that the server recognizes the token to be able to submit the job. But then the error happens during the GP execution when it tries to import the packages.

The GP works well if I run it from Pro or REST service

0 Kudos