One Star

[resolved] Problem: tRESTResponse Not Giving Data Passed in a JSON Request

Hi,
I have a job that should:

Accept a JSON or XML document as request (tRESTRequest - HTTP Verb: POST, Consumes: XML or JSON, Produces: XML or JSON)
Get the field values from the request document at the first tXMLMap and pass them onto tLogRow
Pass the field values from tLogRow to the next tXMLMap
Create the response document at the second tXMLMap and pass it onto tRESTResponse component
Job design is shown below:

I am using SoapUI for testing and when I send in an XML document (SoapUI Media Type: application/xml) as request (ID as 123), tLogRow prints the ID and I get the XML document as response with the ID number 123 present in the ID tag (Shown in the two screenshots below).


The problem is that when I send in a JSON document (SoapUI Media Type: application/json) as request (Again ID as 123), tLogRow does not print the ID and I get an XML document as response but the ID tag is empty (Shown in the two screenshots below). Also, I checked the JSON tab in SoapUI response section and it shows <Not JSON content> which makes me think (Please correct me if i am wrong) that the response is always an XML document although at tRESTRequest component has "XML or JSON" under the "Produces" column in rhe REST API Mapping section under the Basic Settings tab.


I would greatly appreciate your help in resolving this issue.
Thanks
1 ACCEPTED SOLUTION

Accepted Solutions
One Star

Re: [resolved] Problem: tRESTResponse Not Giving Data Passed in a JSON Request

Problem solved, it was to do with the square brackets. Changing to curly braces worked.
Many thanks andrey.s
2 REPLIES
One Star

Re: [resolved] Problem: tRESTResponse Not Giving Data Passed in a JSON Request

I'm not sure it is the reason, but according to your screenshot your JSON has an array in object "Company". Will it work if you will change this array to a single object? In other words, just change "" to "{" and "}".
One Star

Re: [resolved] Problem: tRESTResponse Not Giving Data Passed in a JSON Request

Problem solved, it was to do with the square brackets. Changing to curly braces worked.
Many thanks andrey.s