Michael Commons
Michael Commons

Reputation: 822

Use response data from a HTTP request to another one Azure

I'm designing a Logic App in Azure, is there any way to make two HTTP request like this : 1. I'm calling my Identity Server 4 to get a new access token 2. I want to get the access token from the first request, put it to header and call .Net Core Api Endpoint with it?

Thanks

Upvotes: 3

Views: 1403

Answers (2)

Md Farid Uddin Kiron
Md Farid Uddin Kiron

Reputation: 22419

per my understanding, you want to know how to get access_token value from a JSON object which comes from response of get token http request . I did a simple demo for you : enter image description here

The details of the post request : enter image description here

This is a simple request to get access token in Azure. the response will be :

{
    "token_type": "Bearer",
    "expires_in": "3600",
    "ext_expires_in": "3600",
    "expires_on": "1557995356",
    "not_before": "1557991456",
    "resource": "<-resource name->",
    "access_token": "<-value of access token->"
}

As you can see this logic app is triggered by http request and it will do a post request to get an JSON object which contains an access_token. And finally it will return the access_token value in response .

So the key here is how to config so that we can get access_token value from the JSON response of step2 .

Let's open logic app code view, find "response" =>"body" and modify its value as : "@body('HTTP').access_token"

enter image description here

So that you can get the certain param from your JSON response of previous http request : enter image description here

Upvotes: 3

Michael Commons
Michael Commons

Reputation: 822

You can use the response of the first request by using Parsing JSON action. enter image description here

Upvotes: 1

Related Questions