It try to simply get the list of projects of Test Manager Texte préformatéfrom the rest api . When on browser already connected to UiPath, it works using the swagger (but the curl command showing it works with the XSRF token).
From Postman, curl on command line or java programming, no way : I tried with a personal access token or an OAuth2 token, sent in header on Bearer, but I always get a 401 Unauthorized response.
Can you please tell me how to do that ?
(Request being /api/v2/projects)
Hi Arnaud,
have you found a solution to this problem? I am facing the same problem. In swagger UI I can use the bearer token without any problems. But in UiPath Studio using the “HTTP Request”-Activity I am facing the 401 problem. The bearer token was extracted from the Orchestrator Authenticate API.
Or is there an authentication method in the Test Manager API?
Once done, fetch the access token. Please note that scope to be provided with certain TM. Permissions to be able to later use this token for test manager endpoints.
And then hit the required endpoint urls of test manager resource.
The ROPC authentication works fine to retrieve the bearer token. I can use it in swagger UI to send messages to the Test Manager API.
But the main problem is sending messages to the Test Manager API when I use UiPath Studio activities like “HTTP Request”. In this case I get a HTTP 401 error. (Even when I use the import method of the HTTP Request Activity I get an 401). The error description is “error_description=“The audience ‘IdentityServerApi, OrchestratorApiUserAccess’ is invalid””
You get this error because the scope you have defined in the external application does not have required permissions.
When you setup an external application, you will need to provide scopes like the one I shared in screenshot above. To create an external application , go to automation cloud->admin-> external applications-> register a new application, add the scopes save it.
More here
Then first try in postman to use the client id, secret and scope from your external application to get an access token.
Post which you can use that token to hit different endpoints.
Once you get it working using postman, you can simply use http request to get access token and then 2nd http request to hit the TM endpoint you want.
Thank you for your help. I have solved the issue. My last problem was the format of my body. It was still in json instead of the format in my content-type.
Info for everyone:
To get an access_token by using the Client ID & Secret from External Application Account use HTTP Request as in the following instructions:
Orchestrator version: 24.10. Standalone
API: baseURL of the Orchestrator + “identity/connect/token”
Header:
accept: application/json
content-type: application/x-www-form-urlencoded
Body: “client_id=APPID&client_secret=APPSECRET&grant_type=client_credentials&scope=TM.Default” Replace ‘TM.Default’ with a scope you need, multiple scopes are possible.
Then you’ll receive a bearer token. Deserialize the json from the response content as jsonResponseContent and parse it by using "Bearer " + Convert.ToString(jsonResponseContent.GetValue(“access_token”)) on the response content.
Use the Bearer token as header info in “Authorization” in subsequent HTTP Requests.
Note: The external application account can only be used in its scope.