1

Sample xml request :

<env:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  <ns5:CreateCustomerProfileRequest>
    <ns5:SourceApplication>
      <ns3:ApplicationID>HYBRIS_01</ns3:ApplicationID>
      <ns3:ApplicationName>Hybris</ns3:ApplicationName>
    </ns5:SourceApplication>
    <ns5:CustomerProfile>
      <ns5:CustomerIdentification>
        <ns5:CustomerIDType>bill-to</ns5:CustomerIDType>
        <ns5:CustomerID>618a18b3f33fa4007f2e76be</ns5:CustomerID>
        <ns5:CustomerNumber/>
      </ns5:CustomerIdentification>
      <ns5:UserId>[email protected]</ns5:UserId>
      <ns5:CustomerType>Customer</ns5:CustomerType>
      <ns5:CustomerAddressBook>
        <ns3:Email>
          <ns3:EmailAddress>[email protected]</ns3:EmailAddress>
        </ns3:Email>
      </ns5:CustomerAddressBook>
      <ns5:CustomerName>
        <ns3:FirstName>Francisco</ns3:FirstName>
        <ns3:LastName>Lopez-puente</ns3:LastName>
      </ns5:CustomerName>
      <ns5:CustomerSleep>35</ns5:CustomerSleep>
      <ns5:ModifiedByName/>
      <ns5:BillToInd>false</ns5:BillToInd>
      <ns5:ShipToInd>false</ns5:ShipToInd>
    </ns5:CustomerProfile>
  </ns5:CreateCustomerProfileRequest>
</env:Body>

Json :

{"body": {
"ProcessName":"SC Account Registration Process",
            "SiebelMessage": {
            "IntObjectName": "SC EAI Contact",
            "MessageType": "Integration Object",
            "IntObjectFormat": "Siebel Hierarchical",
            "ListOfSC EAI Contact": {
                "Contact": 
                {
                    "Email Address": "[email protected]",  
                    "First Name": "SRI",
                    "Last Name": "TEST",
                    "SC External Customer Id":"1234aew",
                    "Integration Id":"1234aew",
                    "Type":"CRM_Unqualified",
                    "SC Sleep ":"35"
 }}}}}

how to convert above xml to above json format using apim policies. please let me know what can we use to get the exact format of the code. Currently i want to use azure azure apim policies for this to do.

2

1 Answer 1

1

As suggested by @DeepDave-MT Based on the MS DOC

To convert xml to json we can use the below example of code in our azure apim policy for this

Policy statement

<xml-to-json  kind="javascript-friendly | direct"  apply="always | content-type-xml"  consider-accept-header="true | false"/>

Then try to add the below example to convert

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.