Richard
Richard

Reputation: 401

Logic Apps - Http+Swagger - Header attribute for token based authentication

I am trying to add headers to a Http+Swagger action in Logic App.

When I add a simple Http Action, I can clearly see the Headers in the designer. However, with Swagger+Http action it disappears.

I am using token based authentication and need to add Header to this API call. Hence, I modified the code view like below but it does not seem to help!

Cannot find much resources with regards to this. Any help is appreciated.

Thank You.

"Information_Process": {
                            "inputs": {
                                "body": {
                                    "fileId": "Test.json",
                                    "items": [
                                        {
                                            "item": {
                                                "prop1": "@items('For_each')?['Item']?['prop1']",
                                                "prop2": "@items('For_each')?['Item']?['prop2']",
                                                "prop3": "@items('For_each')?['Item']?['prop3']"                                               
                                            }
                                        }
                                    ]

                                },
                                "headers": {
                                    "Authorization": "@{concat('Bearer ',variables('BearerTokenValue'))}"
                                },
                                "method": "post",
                                "uri": "https://appone.azurewebsites.net/api/information/proccessing"
                            },
                            "metadata": {
                                "apiDefinitionUrl": "https://appone.azurewebsites.net//swagger/docs/v1",
                                "swaggerSource": "custom"
                            },                           
                            "type": "Http"
                        }

Upvotes: 5

Views: 771

Answers (1)

HariHaran
HariHaran

Reputation: 4119

The official documentation states to make use of the parameters to send and receive a token.

"parameters": {
               "secret": {
                  "type": "SecureString"
               }
            }

Or you can try like this

"HTTP": {
    "inputs": {
        "headers': { 
        "Authorization": "@concat('Basic ', base64('username:password'))",
        "Content-Type ": "application/json"
    },
    "method ": "GET ",
    "uri": "someurl"
   },
   "runAfter": (),
   "type": "Http"
   }

enter image description here

Upvotes: 2

Related Questions