API Connect

API Connect

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Text/XML to JSON tranformation

    Posted Fri December 23, 2022 02:48 AM
    Hello Team,

    We have recieved response in Text/XML format (Respose payload is XML and Contetnt-type is "*/*"), we need to transform it to JSON format. In XML response payload, the encoded type is  "utf-16".

    Please help how to transform XML to JSON.

    Eg:
    <?xml version="1.0" encoding="utf-16"?>

    ------------------------------
    Jyoti Yadav
    ------------------------------


  • 2.  RE: Text/XML to JSON tranformation

    Posted Fri December 23, 2022 03:03 AM
    Hi  Jyoti,

    I suggest you take a look at the XML to JSON policy - XML to JSON
    Ibm remove preview
    XML to JSON
    Use the XML to JSON policy to convert the context payload of your API from the extensible markup language (XML) format to JavaScript Object Notation (JSON).
    View this on Ibm >


    ------------------------------
    Ricky Moorhouse
    IBM API Connect Cloud Architect
    ------------------------------



  • 3.  RE: Text/XML to JSON tranformation

    Posted Mon December 26, 2022 10:30 PM
    Hello Team,

    Using xml to json policy, unable to transform "utf-16" encoding xml to json.
    " getting bad request error" for xml while transforming it to json.





  • 4.  RE: Text/XML to JSON tranformation

    Posted Tue December 27, 2022 02:01 PM

    Hi Jyoti,
    You may want to try an identity stylesheet that specifies the utf-16 encoding on the xml declarative of the stylesheet. The output will go to message.body as an equivalent utf-8 which would be consumed by the xml to json policy. For the error you are currently seeing, do you see any related log messages in the DataPower default logs?


    Best Regards,
    Steve Linn



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------