tREST with POST method in JSON format throwing error.

Hello Everyone,
I am new to Talend and web services. I need your help on this.
the version of Talend that I have is Talend Open Studio for Big Data(Version: 6.1.0).
I am trying to connect to an external web service to fetch data. I have used tREST component for the workflow.
Method is : POST
HTTP Headers: 'Content-Type', 'application/json'
                          'Accept', 'application/json'
                    'Transfer-Encoding', 'chunked'
HTTP Body : {
  "authDetails": {
    "memberId": "mid",
    "userId": "uid",
    "sessionKey": "sKey",
    "role": "Pittch"
                  },
  "resId": "201503271601FLYWALL_USEQUITY_424",
  "showChain": true,
  "getWirename": false,
  "getPhotoInfo": false
}

When I check the code it is giving me the following error message.
Error code:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
                Invalid character constant
                 at big_data.trest_0_1.tREST.tREST_1Process(tREST.java:562)
                at big_data.trest_0_1.tREST.runJobInTOS(tREST.java:991)
                at big_data.trest_0_1.tREST.main(tREST.java:848)

The code block that is throwing the error is
com.sun.jersey.api.client.ClientResponse errorResponse_tREST_1 = null;
       String restResponse_tREST_1 = "";
       try{
             restResponse_tREST_1 = restResource_tREST_1
             
              .header("content-type","application/json")
             
              .header("accept","application/json")
               
             
                     .post(String.class,{    "authDetails":     {      "memberId": "mid",      "userId": "uid",      "sessionKey": "sKey",      "role": "Pittch"    },    "resId": "201503271601FLYWALL_USEQUITY_424",    "showChain": true,    "getWirename": false,    "getPhotoInfo": false  });
             
       }catch (com.sun.jersey.api.client.UniformInterfaceException ue) {
        errorResponse_tREST_1 = ue.getResponse();
Can someone please help me in getting this resolved.
Thanks for your help in advance.
Nikki.
2 REPLIES
Moderator

Re: tREST with POST method in JSON format throwing error.

Hi,
Have you already tried to use tRestClient component to post a request with your json format to see if it works?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: tREST with POST method in JSON format throwing error.

Hi,
I am new for talend, i am also facing same issue, not able to achive this even with tRESTclient
could any one please let me know with example
Thanks
shareen