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
A direct tRESTRequest to tXmlMap link should work; tRESTRequest would auto-convert JSON to DOM4J and tXMLMap would deal with it. I do not have a demo job available right now, sorry. When I said "process as needed" I referred to the alternative option, where no tXMLMap is used but tExtractJsonField is used instead - I've no experience of working with that component though.
Cheers, Sergey
Anonymous
Not applicable
Author

Thanks for your clarification. I just need to know if this is the ONLY way to process incoming REST requests, exploring as wide a range of TOS ESB's capabilities in our POC, comparatively to other ESBs like Mule, Informatica.
Anonymous
Not applicable
Author

Np, it is def not the only way, as far as the parsing of the incoming JSON requests is concerned. The 2 options we've discussed are about extracting the individual properties from a JSON payload. One can also get a String payload and process it with a favourite JSON library from tJava or save it directly if needed. I'm referring to tXmlMap because I was a bit involved in the relevant development but indeed auto-converting to tXMLMap is not the only option
Cheers, Sergey
Anonymous
Not applicable
Author

Thank you. tJava is custom and certainly a way to hand-code. Would it be safe to assume from a prebuilt Talend component point-of-view that none of tExtractJSONfields, tWriteJSONFields, (tFileInputJSON reads in json) nor any other t*JSON* Talend component can extract JSON payload from tRestRequest? If so, we can continue to use tXMLMap.
Anonymous
Not applicable
Author

The example at
https://help.talend.com/display/TalendComponentsReferenceGuide54EN/tExtractJSONFields
suggests that tWritejsonfield produces a String that is then fed into tExtractJsonField.
So as I said you can set a given tRESTRequest's flow schema to have body 0683p000009M9p6.pngtring and have tExtractJsonField directly connected to tRESTRequest.
Another alternative is to use an advance mapping component,
http://www.talend.com/advanced-mapping-and-transformation
I believe it is available via a separate download...
Anonymous
Not applicable
Author

Thanks Sergey. I am trying exactly that--a tRestRequest linking its body flow to tExtractJsonFields but somehow not yielding. Let me attach screenshots of my configuration and perhaps I am missing something obvious?
0683p000009MANg.png 0683p000009MANl.png 0683p000009MAJQ.png 0683p000009MANq.png 0683p000009MAGm.png 0683p000009MAIY.png 0683p000009MANv.png tRestRequest_to_toExtractJSONFields.txt.txt
Anonymous
Not applicable
Author

Thank you both, Sergey and SHong, for your patience and confirming tExtractJSONFields works linked directly after tRestRequest. Even as I posted, realized my own mistake. I fully qualified the xpath "Consents/consent" again (as I tried it earlier under different circumstances), cleared the GetNodes and GetArray checkboxes and now it works. 
You may close this now.
Anonymous
Not applicable
Author

OK, thanks for your feedback!
Shong
_AnonymousUser
Specialist III
Specialist III

Thank you both, Sergey and SHong, for your patience and confirming tExtractJSONFields works linked directly after tRestRequest. Even as I posted, realized my own mistake. I fully qualified the xpath "Consents/consent" again (as I tried it earlier under different circumstances), cleared the GetNodes and GetArray checkboxes and now it works. 
You may close this now.

Hi Mlting, Could you please post a video how to get JSON fields directly from tRestRequest's payload. Here you concluded that you achieved success. But I was struck here. Thanks in advance.
Anonymous
Not applicable
Author

Hi Mlting, 
Same here. I am too stuck at the same point. It would be helpful if you can share a video or sample job.
Thanks,
Ashish