Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
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

For the component tRestClient, you don't need to put both body and string in the same time. If you want to put a xml, you use body, if not, you put just in string. There is not the option 'Convert Response To DOM Document' in the version 5.5.1? I use the version 6. Could you put a screenshot of 'Advanced settings' for your component tRestClient?
Lin LIN
Consultant BI/Talend
Synaltic Group
Anonymous
Not applicable
Author

For the component tRestClient, you don't need to put both body and string in the same time.

You need to, otherwise it won't compile.
You can see that there is now 'Convert Response To DOM Document' option.
Anonymous
Not applicable
Author

You can see that there is now 'Convert Response To DOM Document' option.
Anonymous
Not applicable
Author

0683p000009MEGJ.png
Anonymous
Not applicable
Author

Can you update your talend to 5.5.2? There is this option from the version 5.5.2.
Lin LIN
Consultant BI/Talend
Synaltic Group
Anonymous
Not applicable
Author

no I cannot upgrade.
Anonymous
Not applicable
Author

For the component tRestClient, you don't need to put both body and string in the same time.

You need to, otherwise it won't compile.
You can see that there is now 'Convert Response To DOM Document' option.
http://imgur.com/f7DfHAx

This is not strictly true. While you need to connect from one component to the tRestClient supplying a "string" and "body" column, they do not both need to actually be populated with anything. 
If you simply supply a correct formatted JSON String to the "string" column and leave the "body" column empty, the service you are calling will receive the JSON. It will be converted to XML and will be received via the body Document column (you will need to create this), but it will be received.
Anonymous
Not applicable
Author

If you simply supply a correct formatted JSON String to the "string" column and leave the "body" column empty, the service you are calling will receive the JSON.

I cannot crete this kind of job.
Can you tell me how to set components to achieve this?
Right now I have consumer job with:
tfixedflow--tXMLmap--tRESTClient
And service with 
tRESTRequest--tXMLmap--RESTResponse
If I do like you said I get null inside 'string'.
Anonymous
Not applicable
Author

I assume you mean that you receive null inside "string" in the service. The service will not receive a "string" value, it will receive a "body" document. The JSON will be translated to a XML document.
Anonymous
Not applicable
Author

It doesnt work.
If on the client side I leave body empty and put JSON inside string and
on the service side if I try to get JSON from the body I get an runtime error.
But this works:
If I put JSON inside XML and inside body and If I set tRESTClient that accepts JSON, I get JSON on the service side from body.