post JSON Request using tRestClient

One Star

post JSON Request using tRestClient

Hi Everyone,
I'm quite new to Talend and I am stuck with posting json request using tRestClient. I browsed through the forum topics. But I could not find an example that posts a json request . Here is one of the scenarios I tried. I have an input json file:
{"name": "months", "levels": }
And here is my job:
tFileInputJSON ----row1 (Main) -->tXMLMap-- output(Main) -->tRestClient-----row4(Response)->tLogRow2
Basic Settings:
tFileInputJSON : Mapping - Column JSonPathQuery
name "name"
levels "$.levels"
I mapped these two to the body(root) of txmlMap. In the tRestClient I changed the content type to be JSON. When I ran the job, this is how my payload looked
<quote>
Http-Method: POST
Content-Type: application/json
Headers: {Content-Type=, Accept=}
Payload: {"name":"months","levels":""}
</quote>
I would expect the payload to be
Payload: {"name":"months","levels":}
Is there a way to send the json request directly to the tRestClient? I assume tXMLMap is a mandatory component before tRestClient as tRestClient needs body and string as the input
I would appreciate if any body could provide a sample job.
Note: I am using Talend Open Studio for ESB (v 5.3)
Thanks
Community Manager

Re: post JSON Request using tRestClient

Hi ssunkara
I am working on your problem, but I am not able to reproduce the problem, can you please export the job and send it to me via email?
Thank you!
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: post JSON Request using tRestClient

Hi All,
I am also facing the same problem. Did you guyes got any solution for the same.
Thanks in advance.
Employee

Re: post JSON Request using tRestClient

Double quotes apparently get escaped somewhere early in the route, Jettison provider won't do it.
FYI, tXMLMap will only be needed if DOM4J to JSON auto-conversion is needed, using a dedicated tWriteJson component may be better indeed.
Actually, you probably need to remove quotes in your configuration.
Sergey