Rahul Dev
Rahul Dev

Reputation: 141

How to use the output of a rest api as an input to another rest api in a logic app

I have a rest api which is running on a recurrence trigger every 30 minutes. To use that api, I'm generating an azure AD token, and I've to pass it as a bearer token to my api. I'm able to generate the token using a post request, but not able to figure out how to use that token as a bearer token to call the api.

The below output shows the raw output results from the http request which generates the token.

{
    "statusCode": 200,
    "headers": {
        "Pragma": "no-cache",
        "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
        "X-Content-Type-Options": "nosniff",
        "x-ms-request-id": "7531f66d-6802-4987-814d-3fa2cad63b00",
        "x-ms-ests-server": "2.1.11239.9 - CHI ProdSlices",
        "Cache-Control": "no-store, no-cache",
        "P3P": "CP=\"DSP CUR OTPi IND OTRi ONL FIN\"",
        "Set-Cookie": "fpc=An_xrSuJS41Gm_JNUNKzHxQQjkvsAQAAAMi5RtcOAAAA; expires=Fri, 18-Dec-2020 06:44:24 GMT; path=/; secure; HttpOnly; SameSite=None,x-ms-gateway-slice=prod; path=/; secure; samesite=none; httponly,stsservicecookie=ests; path=/; secure; samesite=none; httponly",
        "Date": "Wed, 18 Nov 2020 06:44:24 GMT",
        "Content-Length": "1377",
        "Content-Type": "application/json; charset=utf-8",
        "Expires": "-1"
    },
    "body": {
        "token_type": "Bearer",
        "expires_in": 3599,
        "ext_expires_in": 3599,
        "access_token": "sometokengettinggeneratedhere"
    }
}

Please explain how to use this access_token as a bearer token while calling the api in logic app.

Upvotes: 1

Views: 513

Answers (1)

Hury Shen
Hury Shen

Reputation: 15734

Pleaser refer to my logic app as below screenshot show: enter image description here

I assume your HTTP action(to get access token) named "HTTP", if its name is "HTTP 2", you need to change the expression to body('HTTP_2')?['access_token']. If name is "HTTP 3", expression should be body('HTTP_3')?['access_token'] and so on....

Upvotes: 1

Related Questions