I am using the HTTP Request action in workflow to authenticate to the target application. The flow is as follows:
I need to authenticate using a PAT then use credentials token from the response of that API call (This was already configured in the workflow and was working successfully when I tested the workflow)
The response from step 1 looks something like this:
I will then need to use the credentials token to pass it to the header to the next HTTP Request action to be able to authenticate. What would be the proper configuration/syntax to get this? And do I put it into a variable by doing a Define Variable step?
Are you not receving the response from token url in JSON format. The access token can be passed in the next request. The token is accessed using
{$.httpRequest.body.access_token}}. You can add a header entry with name as Authorization and value as “Bearer {$.httpRequest.body.access_token}}”
Are you able to get the token response via Postman? Can you share the screenshot of the Postman console for the request/respone (masking the sensitive fields)?
@jasmedina Are you trying to onboard application using web services connector? Or the issue is with the HTTP request operation in Workflows?
The mention screenshots are from web services connector page.
In Workflows I don’t think you need to capture the access token from one to other (I may be wrong). In each HTTP operation we need to define the authentication parameters in order to authenticate irrespective of previous operation.
This looks fine. As the response is in XML, not sure how to use the variables. In the response body, I can see “token” as a variable. Can you try {{$.HTTPRequest.body[‘//credentials/@token’]}}. If not put send email operator after the HTTP request that is being called to get access token and see if you were able to get the access token using {{$.HTTPRequest.body[‘//credentials/@token’]}}
Hi @JackSparrow! I tried the {{$.HTTPRequest.body[‘//credentials/@token’]}} in the Send Email operator but it is throwing an error. I also tried the following but it is not returning anything
Hi @JackSparrow! I was able to make it work by adding the header Accept application/json to the first HTTP Request (the one that generates the token) to output the response body to JSON instead of XML. I then used {{$.hTTPRequest.body.credentials.token}} in the next HTTP request to retrieve the token.
Thank you so much for your insight, it pointed me to knowing that the response must be in JSON instead of XML. Appreciate the help!