One Star

[resolved] How to pass POST data to tRESTRequest Component properly

I've followed the tutorial on creating RESTful Web Services from: http://talendforge.org/tutorials/tutorial.php?language=english&idTuto=104
But the tutorial is a bit lacking on creating a POST REST Web Service.
I've played around it a bit but I'm not sure why the payload passed to the tRESTRequest doesn't propagate properly.
I ticked the "Log messages" option in tRESTRequest so I saw that the payload is received by the tRESTRequest component. But after the tXMLMap, the value of the payload is already null.
I'm attaching an image of the job components, including the component view of the tRESTRequest and tXMLMap, the rest client which I used to send the post request, and the logs of the result.
Thanks in advance.
1 ACCEPTED SOLUTION

Accepted Solutions
Employee

Re: [resolved] How to pass POST data to tRESTRequest Component properly

Hi, to get the XML body mapped you need to add a 'body' parameter of type Document; you only need to qualify the parameters, such as queries, headers, URI path values; this is also done for form payloads as in your case, or for multipart payloads
HTH, Sergey
8 REPLIES
Employee

Re: [resolved] How to pass POST data to tRESTRequest Component properly

Hi
You have a form payload, so you can either
- add a 'body' parameter of type String and then parse it manually or
- add parameters with the names matching those in the form payload and 'qualify' then by updating 'Comments' with the value 'form', no quotes
HTH, Sergey
Employee

Re: [resolved] How to pass POST data to tRESTRequest Component properly

Sorry, did not see all of your images; just update Comments and it should work
One Star

Re: [resolved] How to pass POST data to tRESTRequest Component properly

Hi sberyozkin, Thank you for your reply. Where could I see the "Comments" section? Under the Documentation tab? Can you refer me a guide or a tutorial on how to do it? Thanks in advance.
I'm using Talend Open Studio for ESB 5.4.1 if that would help.
One Star

Re: [resolved] How to pass POST data to tRESTRequest Component properly

Thanks sberyozkin, that tip on "qualifying" parameters worked when I was passing form data. How did you know about that? Is there a documentation on those tips? Smiley Happy
Thank you very much! What I'm working on right now is passing an XML post data, is there also some things that I need to do to "qualify" the post data? Thanks in advance.
Employee

Re: [resolved] How to pass POST data to tRESTRequest Component properly

Hi, to get the XML body mapped you need to add a 'body' parameter of type Document; you only need to qualify the parameters, such as queries, headers, URI path values; this is also done for form payloads as in your case, or for multipart payloads
HTH, Sergey
One Star

Re: [resolved] How to pass POST data to tRESTRequest Component properly

Thank you very much Sergey! That clears some things up. Hope this also help other users. Smiley Happy
Regards,
Maki
One Star

Re: [resolved] How to pass POST data to tRESTRequest Component properly

Thanks for this post ! it solved my problem. And Maki is right, how could you find that !?!?! Crazy to put some logic on a comment field !
But not complaining! everything works well ! Great product!
Employee

Re: [resolved] How to pass POST data to tRESTRequest Component properly

Cool.
You are right that using a comment filed is not exactly type safe :-). But we had to use the available tooling-level fields at a time of designing tRESTRequest.
We have some ideas on how to make it all much more wizard- and user- friendly and hopefully at some point in the future it will be realized...
Sergey