Mostafa Bouzari
Mostafa Bouzari

Reputation: 10240

how to get a value of http response in logic apps

i'm trying to get one value of the http response. which looks like this:

"body": {
    "token_type": "string",
    "expires_in": "number but as string",
    "ext_expires_in": "same",
    "expires_on": "same",
    "not_before": "number but as string",
    "resource": "string",
    "access_token": "string"
}

i tried this expression in Set a variable: body('parse_JSON')?[variables('access_token')] which returned this error.

InvalidTemplate. Unable to process template language expressions in action 'Set_Access_Token' inputs at line '0' and column '0': 'The template language expression 'body('Parse_JSON')?[triggerBody()?['access_token']]' cannot be evaluated because property '' cannot be selected. Please see https://aka.ms/logicexpressions for usage details.'.

my workflow looks like this at the moment:

enter image description here

how can i get access_token value?

Upvotes: 0

Views: 5357

Answers (1)

SwethaKandikonda
SwethaKandikonda

Reputation: 8244

This can be done in 2 ways

WAY - 1

You can use Parse JSON action and extract the required variables which are directly generated. Below is the flow of my logic app.

enter image description here

Json Schema

{
    "type": "object",
    "properties": {
        "body": {
            "type": "object",
            "properties": {
                "token_type": {
                    "type": "string"
                },
                "expires_in": {
                    "type": "string"
                },
                "ext_expires_in": {
                    "type": "string"
                },
                "expires_on": {
                    "type": "string"
                },
                "not_before": {
                    "type": "string"
                },
                "resource": {
                    "type": "string"
                },
                "access_token": {
                    "type": "string"
                }
            }
        }
    }
}

RESULTS:

enter image description here

WAY - 2

You can use the below expression to extract access_tokenfrom the request.

body('Compose_2')?['access_token']

In your case its

body('HTTP_to_Refresh_Fibo')?['access_token']

enter image description here

RESULTS:

enter image description here

Upvotes: 0

Related Questions