cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

JSON to XML error Rest

former_member190536
Participant
0 Likes
3,970

Hello,

I am using REST Adapter to receive JSON format message in PO.

the normal XML work for me, but when we have ATTRIBUTES in our strucutre then the json to xml conversion error is coming due to this in mapping the message gets failed.

My target xml strucutre like this.

<CalculationBaseQuantity unitCode="KG">1</CalculationBaseQuantity>

in my source JSON  it is coming like this..

                            "CalculationBaseQuantity": {

                                "-unitCode": "KG",

                                "#text": "1"

After Seder adapter the message come in mapping as ...

<CalculationBaseQuantity><-unitCode>KG</-unitCode><#text>1</#text></CalculationBaseQuantity>

due to this mapping getting failed as xml formatting issues.

error in mapping - The content of elements must consist of well-formed character data or markup., BaseRuntimeException: The content of elements must consist of well-formed character data or markup., BaseRuntimeException: The content of elements must consist of well-formed character data or markup.,

does standard REST adapter wont support this functionality? does i need to go for Custom adapter only?

View Entire Topic
anupam_ghosh2
Active Contributor
0 Likes

Hi Khaja,

                  Can you pls provide the complete json input and complete xml as required by mapping.

Regards

Anupam

former_member190536
Participant
0 Likes

My source JSON

"CalculationBaseQuantity": {

"-unitCode": "KG",

"#text": "1"

I want to convert into XML.

REST Adapter is converting into XML as follows..

<CalculationBaseQuantity><unitCode>KG</unitCode><text >1</content></text>

Expected XML in mapping required as follows..

<CalculationBaseQuantity unitCode="KG">1</CalculationBaseQuantity>

Due to this I am getting error in mapping as follows.

So how should my JSON format required to form this correct xml?

apu_das2
Active Contributor
0 Likes

Hi Khaja,

Define this field as attribute in sender CC Custom XML/JSON conversion table and look how this behave.

Thanks,

Apu

anupam_ghosh2
Active Contributor
0 Likes

Hi Khaja,

                 Can you please confirm if your source json is exactly shown below

{

  "CalculationBaseQuantity": {

    "-unitCode": "KG",

    "#text": "1"

  }

}

Can you please confirm version of PI and service pack you are using.

Regards

Anupam

former_member190536
Participant
0 Likes

yes Anupam, it is same as you mentioned above.

{

                            "CalculationBaseQuantity": {

                                "-unitCode": "KG",

                                "#text": "1"

}

tried with multiple cases like  with "@unitCode":"KG",  "$":"1" 

"_unitCode":"KG",  "$":"1" . etc...

in all cases xml is not forming attribute field unitCode  and in mapping getting failed.

I am using PO 4.0.