You are not logged in.
I have a job that is a REST service in which I use XML to pass data to and it returns XML. The data is posted to it using POST.
So in the job I mapped for the incoming an field named id
However I do not know how to pass the data to it. I did a POST (content type application/xml ) with an xml like this:
But the job in talend fills in null for the id. I am not exacly sure what the problem is, is my POST data structure not correct? or is it not possible to use the tRESTREquest directly like this with an incoming XML and should another component extract the XML fields from the RestRequest?
The id field in the input will only be filled if you have an ID in URL pattern, like
The body will be however put in the flow, please use tXMLMap after tRESTRequest to parse it.
Hi, I want to use POST with XML data with the REST service, so your solution will not work for me. But I found the problem, the body type of the rest service was set to String instead of Document.
I set it to Document and after that I can use tXmlMap to access the XMl fields.
I would like to create a trest service too, with a similar sheme.
Do you use trest to test the trest service ? can you provide an example of the structure of an http post via trest ?
i run the service in talend with http://localhost:8095/service and trest with the same (in talend too), i get the 415 error status
25 mai 2012 16:07:13 org.apache.cxf.jaxrs.utils.JAXRSUtils findTargetMethod ATTENTION: No operation matching request path "/service" is found, Relative Path: /service, HTTP Method: POST, ContentType: text/plain, Accept: text/html,image/gif,image/jpeg,*/*,*/*;q=.2,. Please enable FINE/TRACE log level for more details.
thanks in advance
Last edited by minchi (2012-05-25 16:33:13)
i correct this error by adding an header : "content-type" "application/xml"
is someone able to provide the configuration of txmlmap between trestrequest and trest response ? i am unable to qualify this content (received by tresrequest).
Last edited by minchi (2012-05-25 17:00:58)
after a tRestClient component, the response is available in a tlogRow.
But if I use a tXMLmap to get xml content, I have no error but no results.
Where is the problem?
Thanks for help
I have similar problems when I try to design a REST Service using PUT or POST methods to insert or update datas in a DB.
I did not find any tutorial about REST Service with output to DB and the PDF documentation about REST Components does not provide such scenario. Only the use case with http GET and a DB input is explained.
If anybody from Talend, who already exprimented this kind of REST Service, could explain the main steps, it would probably help many users !
I've created a short tutorial how to use the tRESTRequest in combination with POST XML below:
1. Create flow as shown in the RESTRequestExampleREST_POST_XML screenshot
--> The body is set to "Document", this will hold the XML payload
2. In the tXML component (see xmlMapExampleREST_POST_XML screenshot), define the schema schema for the body, in this case I used a simple schema:
3. Map the xml fields to your target schema, in this case "messageContent" of type String
4. The messageContent is printed using the tLogRow (using TablePrint)
5. The tRESTResponse is default (returns 200 OK)
Now, start the job and run the command below to test:
curl -X POST -H "Content-Type: application/xml" -H "Accept: application/xml" -d "<root><id>123</id></root>" http://127.0.0.1:8090/myRESTService/publishId
As a result, you have the tLogRow component printing the value of <id>:
| tLogRow_1 |
Last edited by rhuiser (2013-02-17 08:42:21)