Why does the xml-to-json policy result in an empty body when using it in the inbound policies?

时间:2019-05-22 18:36:45

标签: azure azure-api-management

Document reference: https://docs.microsoft.com/en-us/azure/api-management/api-management-transformation-policies#example-1

A snippet from my "inbound processing" policies:

<inbound>
   <base />
   <xml-to-json kind="direct" apply="always" consider-accept-header="false" />
</inbound>

Problem: When I apply this policy in "inbound processing" the backend API (Logic App) that is called is given an empty body. The API receiving this request shows Content-Length = 0.

Results from trace:

xml-to-json (0.697 ms)
"XML-to-JSON policy was applied. Original Content-Length header was removed as its value was invalidated. Content-Type header was set to 'application/json'."

Notes: When I apply this exact same policy in the "outbound processing" policies, I get the result I am expecting as JSON.

Basic XML example I am sending:

<note>
    <to>PersonOne</to>
    <from>PersonTwo</from>
    <heading>Test</heading>
    <body>Example</body>
</note>

Result I get when policy is applied to in "outbound policies" section (This is working as expected):

{
    "note": {
        "to": "PersonOne",
        "from": "PersonTwo",
        "heading": "Test",
        "body": "Example"
    }
}

0 个答案:

没有答案
相关问题