Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Zurich on Sept 24th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
iamabhishek
Creator III
Creator III

tRestClient response received is not in correct format

We are trying to use tRestClient to get corresponding responses from a REST webservice and extract the data and bring to our use. 

But the response when received is a bit off as 'body' is received as null where-else we have the complete content of response from the server end in 'string'.

'HTTP Method' is 'GET'

'Accept Type' is 'Any'

 

The response received when printed using tLogRow -

|statusCode|body|string |
|=---------+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------=| |200 |null|{ "items" : [ { "Salutation" : null, "FirstName" : "Jessica", "MiddleName" : null, "LastName" : "Ashley" ], "count" : 10, "hasMore" : true, "limit" : 10, "offset" : 0, "links" : [ { "rel" : "self", "href" : "https://///emps", "name" : "emps", "kind" : "collection" } ] }

Let me know if any more information is required on this, thanks in advance for any help.

Platform: Talend Open Studio for Data Integration Version: 6.5.1

Labels (3)
15 Replies
Anonymous
Not applicable

What are you expecting back? If you are expecting XML, you will need to show us your API and configuration of your Talend component. If you are expecting JSON, this is JSON and it will always be a String. The Body is a document and that is XML.

iamabhishek
Creator III
Creator III
Author

I am expecting the response to be in JSON format as at the next step I am using tExtractJSONFields to extract different individual nodes from the response content.
I was expecting the response to be received in 'Body' rather than 'String' that's why at tExtractJSONFields I am mention JSON field to - 'Body' and then using JSONPath query and other mappings.
Should I change the same to 'String' at tExtractJSONFields and give it a go?

Anonymous
Not applicable

Body is named poorly to be honest. It is hardcoded as a Document. This is an XML format. You need to change your receiving component to accept the String field. JSON (while referred to as a document by people, is actually a String).

iamabhishek
Creator III
Creator III
Author

Thank you @rhall.

I did the changes so that tExtractJSONFields read the JSON response from JSON Field "string". Now the rpoblem is whatever I use to read "JsonPath" or "XPath" this would not extract anything out.

 

So, got the response and stored it in a json file and used tFileInputJSON and did a "JsonPath" read of the data with the same Loop Json Query & Json Query which gave the output pretty much nicely.

 

0683p000009LxWC.jpg

 

Anonymous
Not applicable

You need to show the output you get, you also need to show your configurations of the components (JSON ones). There is nothing wrong with Talend here as I do this all the time, there will be an issue with your configuration. I can't help unless you show me the config though

iamabhishek
Creator III
Creator III
Author

That's what I had also suspected as the response when put on a file and parsed worked fine.

Here you go the details, let me know if this would be enough or more info would be required.

0683p000009LxZ5.jpg

Anonymous
Not applicable

I'm afraid I cannot see the images clearly enough. But something has raised a suspicion as to whether your previous example shows the same JSON being processed by the same code. The first job shows 1 row from the service being converted to 6 rows. This can ONLY be because of the looping finding 6 loops. SO that is working. But in the second example you have 1 row coming out. This means either the JSONPath expressions are not the same or the data is not the same.

iamabhishek
Creator III
Creator III
Author

My bad, I had tried something out in between the posts and posted that but not the original one for which the conversation started.

The below are for the process which has 1 row from the service being converted to 6 rows.

Let me know if the screenshots are bit clear now - 

0683p000009LxZK.jpg

0683p000009LxZU.jpg

 

Anonymous
Not applicable

Your JSONPath looks wrong. Why are you not setting the Loop to $.items[*] ?

 

When I asked for the JSON I meant as text. That way I could quickly knock something up to test. Also, if you have a working solution and one that is not, it would be useful to see both. I suspect that you are using the "JsonPath without Loop" option in the file based one.