问题
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
回答1:
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.
2. In next page, click "Request" tab and click "Add representation" to add "application/json".
3. Then click "New definition"
4. Input the json sample of request body, it will generate the schema automatically in "Payload" box.
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.
来源:https://stackoverflow.com/questions/65696387/how-can-i-pass-body-parameters-to-api-post-operation-using-api-management-action