One Star

tRESTclient Issue

I am having a difficult time with configuring a job that takes a JSON formatted file and posts it to a RESTful service.  I have Talend Open Studio 6.1.1.20151214_1327.  The components are setup as tFileInputJSON à tXMLMap à tRESTClient.  I either get an error 204 (no data) or an error 400 (bad data) with the variety of configurations that I use.  A lot of the forums focus on XML payload but not so much with JSON.  When I use tFixedFlowInput and then manually put in some JSON data and then point to tRESTClient, it posts with no issues.  I can’t use that component.
I have seen many posts about different tRESTClient issues but none of them have proved fruitful.  My JSON data is pretty simple.
{element1row1:value1row1,element2row1:value2row1,.....
{element1row2:value1row2,element1row2:value1row2.....
no complex looping.
2 REPLIES
Community Manager

Re: tRESTclient Issue

It seems you don't extract the data from the source file with tFileInputJson, maybe you don't configure the component settings correctly. For testing, you can use a tlogrow after tFileInputJson to print the data on the console to check if the data is read correctly.
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tRESTclient Issue

Shong,
After enabling some more verbose logging, I noticed why it is not working.  When I use tFixFlowInput --> tRESTClient --> tLogRow, I am able to post.  The post is working because the payload has a bracket as the leading and trailing characters.  Below is what prints out from the log.  I confirmed that my data is appearing in my DB.
Payload:
However, when I use tFileInputJSON --> tXMLMap --> tRESTClient --> tLogRow OR tWriteJSONField  --> tRESTClient --> tLogRow, the payload ends up without the brackets like below and I get an error 400 (bad data).
Payload: {"number":39980,"partNumber":"020116-ESY1","partRev":"B","orgCode":21,"orgName":"Scomo","qtyValues":"1500,1000,700","dueDate":"11-05-2016","completedDate":"","deliveryDate":"12-07-2020","expedite":true,"sourceRequired":false,"longTermAgreement":true}.
I can't seem to get it to include the brackets.  They do exist in my source data file but they get stripped out for some reason.  I need to use FileInput or tWriteJSON for my project so how do you put leading/trailing brackets into the payload?