Search code examples
azureazure-logic-apps

How can I pass Body Parameters to API Post operation using API Management Action in Logic App?


I have an azure function which works well when I call it from postman . I am trying to invoke the same from logic app as when an HTTP request is received. However, I am unable to pass raw content in the APIM as it does not give me an option for the same. It let me add only the subscription key. My Azure APIM accepts file name, subscription key only.

Any help in this regard is much appreciated.

Postman : (I have added Headers - Content-Type, Accept: using )

Headers: Content-Type : Accept: Ocp-Apim-Subscription-Key

Body: { "name": "olaf" }


Azure Logic App: (Using Peek Code);

{ "inputs": { "method": "post", "headers": { "Accept": "application/json", "Content-Type": "text/csv" }, "pathTemplate": { "template": "/scg-liquidTransformer-functionApp/liquidtransformer/{liquidtransformfilename}", "parameters": { "liquidtransformfilename": "@{encodeURIComponent('xmlsample.liquid')}" } }, "api": { "id": "/subscriptions/XXXXXXXXXXXXXXXXXXXXX/resourceGroups/scg-mel-dev-arg-liquidtransformer/providers/Microsoft.ApiManagement/service/scg-liquidTransformer-functionApp-apimservice/apis/scg-liquidtransformer-functionapp" }, "subscriptionKey": "XXXXXXXXXXXXXXXXXXXXXXXX" } }

I need to send body {} as a parameter input in the azure functionenter image description here.

Thanks, Paul.

enter image description here


Solution

  • You need to do configuration in your APIM, please refer to the steps below:

    1. Go to your APIM, find your api and click the "pencil" icon. enter image description here

    2. In next page, click "Request" tab and click "Add representation" to add "application/json". enter image description here

    3. Then click "New definition" enter image description here

    4. Input the json sample of request body, it will generate the schema automatically in "Payload" box. enter image description here

    5. Click "Save", then go back to your logic app and add the APIM api. You can find there is a field "name" for you to choose. enter image description here