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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] tRestRequest with JSON Parameter

Hello,
i'm having problem to develop a simple REST service call where i pass to it a JSON information in one of the fields and print it on the console the table result with the data. The questions and the problem are:
- I don't know what the kind of the field on Output flow parameters, have tried Object, Document and String but doesn't work.
- Is it possible to do that on talend open studio for ESB?

Json:{"Aluno":}
0683p000009MANC.jpg0683p000009MANH.jpg0683p000009MANM.jpg0683p000009MANR.jpg

Labels (4)
20 Replies
Anonymous
Not applicable
Author

Hi,
Please have a look at the online component reference TalendHelpCenter:tExtractJSONFields
Best regards
Sabrina
Anonymous
Not applicable
Author

Hello lecom
I am trying to do something similar, ie retrieving a JSON file using tRESTRequest and parsing it with tExtractJSONFields.
Did you succeed in your case?
If so can you describe how you achieve it?
thanks in advance for your help.
Anonymous
Not applicable
Author

Hi
Given ":{"Aluno":}",
if we use tRESTRequest, accepting/consuming JSON, with the body type set to Document, then connecting it to tXMLMap will do the internal JSON to XML auto-conversion;
I guess we will have something like this in XML:
<ALUNO>
<NOME>João</NOME>
<NOME>Maria</NOME>
<NOME>Pedro</NOME>
</ALUNO>
tXMLMap should help you handle it further.
Alternatively, set tRESTRequest body type to String and feed it into one of Studio components reading JSON
HTH, SErgey
Anonymous
Not applicable
Author

Hello, I have a similar challenge on a requirement for a REST POST service, with tRestRequest reading a JSON POST payload and writing the results to an Oracle database. 
I tried tExtractJsonFields directly linked to tRestRequest and it seems unable to read the column nodes despite various xpath combinations. My tLogRow comes up empty. The same message is readable from a saved (on disk) JSON file using tFileInputJson, but we need this to be from an incoming tRestRequest.
I looked into tWriteJsonField as well, but just like the documentation on tExtractJsonFields, it doesn't seem any of these Talend JSON components can take tRestRequest strings and convert them into columns writeable to relational database.
Can somebody point out an example of how this works and confirm what components can read directly from tRestRequest? tXMLMap is unable to import JSON metadata, just XML so it doesn't seem to be the proper approach either?
Anonymous
Not applicable
Author

Hi
If you link tXMLMap to tRESTRequest then the incoming JSON will be auto-converted to XML, a given tRESTRequest flow's schema should have a 'body' of type 'Document' set for it to work.
Alternatively, set a body type to String, log it to confirm you have a payload coming in, and then process as needed...
Cheers, Sergey
Anonymous
Not applicable
Author

Thank you for the confirmation, Sergey. This method.." Alternatively, set a body type to String, log it to confirm you have a payload coming in, and then process as needed.."  ..was as per your last post.  
We prefer not to convert to XML and then to SQL. Can you explain or have examples on how we convert the incoming JSON payload in a String directly to SQL database? It seems the current transformation components read from a fixed file, not from a tRestRequest directly. I have tried various combinations using tExtractJsonFields and it just comes out null.
Anonymous
Not applicable
Author

I have been able to use tXMLMap but don’t know what follows  “..process as needed.” Would you kindly offer an example of what t component(s) to use right after tRestRequest? I have not been able to make tExtractJsonFields work and am thinking it’s not proper to link directly to the Request? The JSON body never appears to make it to the component. Here are my screenshots of the job design and component definitions
0683p000009MANS.png 0683p000009MANW.png 0683p000009MANb.png
Anonymous
Not applicable
Author

Hi 
What is the data type of body on tRestRequest? Try to check the 'log message' box in the advanced setting panel of tRestRequest to print the log message on the console, so you could see the exact data received by the web service. Such us:
ID: 1
Address: http://localhost:8088/
Encoding: ISO-8859-1
Http-Method: POST
Content-Type: application/json
Headers: {Accept=, Cache-Control=, connection=, Content-Length=, content-type=, Host=, Pragma=, User-Agent=}
Payload: {"person":{"id":1,"name":"shong"}}

Best regards
Shong
Anonymous
Not applicable
Author

Hi SHong, I have clipped the output from tRestRequest. 
tRestRequestSpool.txt.txt