Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

POST request with JSON data to tRESTClient component

How can I create POST request with JSON data using tRESTClient component? I can only successfully send XML Document. Should I put JSON data inside XML element? It seems that is the only way to send JSON data. I am using talend 5.5.1.
Labels (5)
35 Replies
Anonymous
Not applicable
Author

You need to set the request header Content-Type to application/json. And no do not mix XML with JSON, this is a terrible idea!
Anonymous
Not applicable
Author

Which component should I use ? tRESTClient or tREST ? I would like to use tRESTClient but it only inputs "Document" type of data and JSON data are String type.
Anonymous
Not applicable
Author

The Document type is quite ok. This is the result of the tXMLMap or another document related components in Talend.
For an REST request you need an document.
Anonymous
Not applicable
Author

So how can I use tRESTClient ? Right now the problem is that JSON data is in String and tRESTClient needs a Document data.
Anonymous
Not applicable
Author

Hello,
In the component tRESTClient, there are two fields : 'body' and 'string'. You need to juste put your string json in the field 'string' of the tRESTClient.
Lin LIN
Consultant BI/Talend
Synaltic Group
Anonymous
Not applicable
Author

when I put string into a tRestclient's string filed I always get null on the other side inside a service. But the body gets through. What am I doing wrong?
Anonymous
Not applicable
Author

The other side you mean the output? In the output, there are also body and string. But it's not body and string of the input. If you choose the option 'Convert Response To DOM Document', the result of the ouput will be put in the body. If not, the result will be put in the string. 
Lin LIN
Consultant BI/Talend
Synaltic Group
Anonymous
Not applicable
Author

On the other side I mean on the service side.
I have 2 jobs, one is consumer that has tRestClient component. The tRestClient component has 2 inputs body and string. I am inputing both body and string. 
The second jobs is a service. In this job tRestResponse component outputs the string and body that was inputed in previosuly mentioned tRestClient component.
My problem is that from tRestResponse component i get out body but not string. String is always null no metter the input.
What should I do so the string won't be null? Right now from tRestResponse component I would also like to recive a string not just body.
Anonymous
Not applicable
Author

I am using talend 5.5.1 and there is no 'Convert Response To DOM Document' option?
Is there something I can do in 5.5.1 version to transfer JSON data to the service and not inside XML?