Json to XML transformation using the default policy does not retain the case of the values in the payload.
lower case boolean values in the payload are converted to upper case.
For eg: "IsEncryptionEnabled": false, in the incoming payload is converted as <IsEncryptionEnabled>False</IsEncryptionEnabled> with the 'F' changed to uppercase.
Is there a way to preserve the case of the values?
The backend applications expect the boolean value to be false in lowercase and errors are seen such as Error in deserializing body of request message ; The string 'False' is not a valid Boolean value.
Here is the policy used:
<json-to-xml apply="always" consider-accept-header="false" parse-date="false" namespace-separator=":" />
incoming jsonpayload and converted XML payload from the APIM trace are as shown below:
{
"source": "set-variable",
"timestamp": "2022-10-18T22:28:07.1616509Z",
"elapsed": "00:00:00.0375891",
"data": {
"message": "Context variable was successfully set.",
"name": "reqBody",
"value": "{\r\n \"DocumentId\": \"85e6d0b7-3133-4429-938d-b095fbb11e20\",\r\n \"ActiveVersion\": 1,\r\n \"Name\": \"OAO 2.0 Flow 1.16.20.pdf\",\r\n \"ExpirationDate\": \"0001-01-01T00:00:00\",\r\n \"Tags\": [],\r\n \"TenantId\": \"40348465-298c-4282-b0c8-9b4f42489d07\",\r\n \"IsDeleted\": false,\r\n \"Status\": \"Uploaded\",\r\n \"LastModified\": \"2022-10-14T17:44:27.8539898Z\",\r\n \"ReferenceId\": \"32411354\",\r\n \"TemplateCode\": \"DefaultStipulation\",\r\n \"ReceivedDate\": \"2022-10-14T17:44:27.8539901Z\",\r\n \"IsAnnotated\": false\r\n}"
}
},
{
"source": "json-to-xml",
"timestamp": "2022-10-18T22:28:07.1616509Z",
"elapsed": "00:00:00.0376710",
"data": "JSON-to-XML policy was applied. Original Content-Length header was updated. Content-Type header was set to 'application/xml'"
},
{
"source": "set-variable",
"timestamp": "2022-10-18T22:28:07.1616509Z",
"elapsed": "00:00:00.0376823",
"data": {
"message": "Expression was successfully evaluated.",
"expression": "context.Request.Body.As<String>(preserveContent: true)",
"value": "<DocumentId>85e6d0b7-3133-4429-938d-b095fbb11e20</DocumentId><ActiveVersion>1</ActiveVersion><Name>OAO 2.0 Flow 1.16.20.pdf</Name><ExpirationDate>0001-01-01T00:00:00</ExpirationDate><Tags /><TenantId>40348465-298c-4282-b0c8-9b4f42489d07</TenantId><IsDeleted>False</IsDeleted><Status>Uploaded</Status><LastModified>2022-10-14T17:44:27.8539898Z</LastModified><ReferenceId>32411354</ReferenceId><TemplateCode>DefaultStipulation</TemplateCode><ReceivedDate>2022-10-14T17:44:27.8539901Z</ReceivedDate><IsAnnotated>False</IsAnnotated>"
}
},