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

PI REST Receiver http_result problem with json objects

pi_guy
Explorer
0 Likes
2,084

Here is a tough one.

I have a REST receiver with custom error handling. When the HTTP response is not 200, I am getting a json with the error description in an object i.e. {"errorCode":"Generic","errors":{"vendorId":"SKYPAI not exist."},"message":"Bad request"}. My custom response looks like:

<?xml version="1.0" encoding="UTF-8"?>

<data>

{http_result}

</data>

For some reason, PI only converts the first part to XML and disregards the object completely so I get:

<data><errorCode>Generic</errorCode></data>

And I cannot fetch the rest of the json whatever I try to do.

Any ideas? I am on 7.5 latest SP and patches.

Thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

pi_guy
Explorer
0 Likes

I managed to work around this by setting the "Add Wrapper Element" flag. I still think there is some kind of bug there that has to do with JSON to XML conversion of objects, but it's working now. (Of course I now have to remove the wrapper in JAVA mapping or XSLT, but that's easy enough)

chandrukan
Explorer
0 Likes

Hi pi_guy,

As per above screenshots, i could see some progress on the issue, to look more on further, please share me each tab REST channel level parameters. especially on the DataFormat tab and ErroHandling tab.

Thanks and regards,

Chandra Kandepalli

chandrukan
Explorer
0 Likes

Hello pi_guy,

Please try below options and do let me know.

Once you maintain these custom details, then you could see proper/standard format json and it will be converted josn to xml(based on data format response format sync).

Also, you can try below option as well incase if the above one doesnt work.

Thanks and Regards,

Chandra Kandepalli

pi_guy
Explorer
0 Likes

This still doesn't work. Please take a look at the mapping steps and how the JSON conversion fails to pick up the data from the JSON object.

Original JSON received:

After conversion:

My data type looks like this:

<data>

....

<errorCode/>

<errors>

<vendorId/>

<factoryId/>

</errors>

<message/>

</data>

Any help would be greatly appreciated. Thanks!