One Star

[resolved] How to use POST method of the tRESTRequest

How can i use the post method of tRESTRequest to insert/update data in my database ? with GET method i can do it but when i switch the http verb of my method to post it dosent work and this is the eroor :
: org.apache.cxf.jaxrs.utils.JAXRSUtils - No operation matching request path "/pays/modify/1/Ma/Ma" is found, Relative Path: /modify/1/Ma/Ma, HTTP Method: GET, ContentType: */*, Accept: text/html,application/xhtml+xml,image/webp,application/xml;q=0.9,*/*;q=0.8,. Please enable FINE/TRACE log level for more details.
: org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper - javax.ws.rs.ClientErrorException
at org.apache.cxf.jaxrs.utils.SpecExceptions.toHttpException(SpecExceptions.java:110)

Solutions ?????
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: [resolved] How to use POST method of the tRESTRequest

For post method, you can't pass value from URL, so you can't define URI pattern like this:
"/add/{code}/{nom}"
If you want to pass value to the rest webservice with post method, you need to define parameters. To do it, type in "query'' in the comment field of column on the schema, and then you are able to access the value of this parameter later with this expression:
(String)globalMap.get("add.code")   // for string type
or 
(Integer)gloalMap.get("add.code")  //for integer type
...
Best regards
Shong 
----------------------------------------------------------
Talend | Data Agility for Modern Business
7 REPLIES
Community Manager

Re: [resolved] How to use POST method of the tRESTRequest

Hi
: org.apache.cxf.jaxrs.utils.JAXRSUtils - No operation matching request path "/pays/modify/1/Ma/Ma" is found, Relative Path: /modify/1/Ma/Ma, HTTP Method: GET, ContentType: */*, Accept: text/html,application/xhtml+xml,image/webp,application/xml;q=0.9,*/*;q=0.8,. Please enable FINE/TRACE log level for more details.

It seems the error occurs when you are trying to call a restful web service. Which version of talend esb product you are using? Can you please upload some screenshtos of your job design?
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] How to use POST method of the tRESTRequest

Am using the version 5.6.1
Screenshots :


Best regards
One Star

Re: [resolved] How to use POST method of the tRESTRequest

My job items and the screenshots
RestJob.zip



Community Manager

Re: [resolved] How to use POST method of the tRESTRequest

For post method, you can't pass value from URL, so you can't define URI pattern like this:
"/add/{code}/{nom}"
If you want to pass value to the rest webservice with post method, you need to define parameters. To do it, type in "query'' in the comment field of column on the schema, and then you are able to access the value of this parameter later with this expression:
(String)globalMap.get("add.code")   // for string type
or 
(Integer)gloalMap.get("add.code")  //for integer type
...
Best regards
Shong 
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] How to use POST method of the tRESTRequest

Thanks a lot for the solution , my broblem is solved .
One Star

Re: [resolved] How to use POST method of the tRESTRequest

Hi,
I know this is old post, but how did you deployed  the job to listen on the server?
I am using simple example from talend help web site for tRESTResponse, works fine on local box, we use Talend Platform... what URL of the endpoint should be on the server?
How to deploy job on TAC?  How did you deploy your job? Can you please explain as I do not know what to use - Job Conductor, ESB Publisher or ESB Conductor...  tried all - none worked.
thanks
One Star

Re: [resolved] How to use POST method of the tRESTRequest

Hi aleksb,
if you start using REST components in our job, you have to deploy with Talend ESB runtime, which is in fact Apache Karaf.
I so far used Tomcat to deploy jobs as servlets, but had to switch to Talend ESB runtime, when starting using REST components.
Quick guide on that, however please review related posts and documentation
* Talend ESB runtime gets installed with ESB automatically
* Start Talend runtime by running "trun.bat" in "\Runtime_ESBSE\container\bin" (on a Windows system)
* Deploy Talend jobs
- Select "OSGI bundle for ESB" when building a job
- Have the resulting jar file created in "Runtime_ESBSE\container\deploy", or copy it there
Deployment can be done while runtime is running - the new service is recognized automaticall
* The endpoint address is the one, that you configure in tRESTRequest
All that actually works quite nicely. On Talend runtime specifics, e.g. setting size of Java memory heap or commands to be used in the console, you may consult Apache Karaf documentation or stackoverflow posts, which are more comprehensive.
Let me know, if this works for you.