How to make the tRestClient work?

One Star

How to make the tRestClient work?

I'm almost embarrassed posting this as it seems so simple it should just work, but I've tried a dozen ways and it still will not pull a response.
I'm requesting a response from SugarCRM API v4_1. With the native Talend connector several versions behind now, I thought just as easy to use SOAP or REST. I have SOAP working fine. However, REST, I'm stuck.
This works in a URL: (password mod for security)
democrm.ela.solutions/service/v4_1/rest.php?method=login&input_type=json&response_type=json&rest_data={"user_auth":{"user_name":"admin","password":"098f6bcd4621d373cade4e832627b4f6"},"application_name":"Suite"}
But when I try to recreate this same post with the tRestClient, it fails no matter what I seem to pass in the parameters. The error "HTTP 500 Internal Server Error" response is the same error I get if I pass no parameters at all on the URL.


And the error is:
Starting job Copy_of_Get_SessionKey_Basic_Rest at 02:15 22/12/2016.
connecting to socket on port 3414
connected
Exception in component tRESTClient_1
javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.apache.cxf.jaxrs.client.AbstractClient.convertToWebApplicationException(AbstractClient.java:507)
    at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:895)
    at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:863)
    at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:426)
    at org.apache.cxf.jaxrs.client.WebClient.post(WebClient.java:456)
    at esb_test.copy_of_get_sessionkey_basic_rest_0_1.Copy_of_Get_SessionKey_Basic_Rest.tRESTClient_1Process(Copy_of_Get_SessionKey_Basic_Rest.java:759)
    at esb_test.copy_of_get_sessionkey_basic_rest_0_1.Copy_of_Get_SessionKey_Basic_Rest.runJobInTOS(Copy_of_Get_SessionKey_Basic_Rest.java:1153)
disconnected
    at esb_test.copy_of_get_sessionkey_basic_rest_0_1.Copy_of_Get_SessionKey_Basic_Rest.main(Copy_of_Get_SessionKey_Basic_Rest.java:1010)
Job Copy_of_Get_SessionKey_Basic_Rest ended at 02:15 22/12/2016.

Any insight would be appreciated! Smiley Happy
Employee

Re: How to make the tRestClient work?

Hi
Should these data go as a POST body ? if yes, set a body type to String and pass that JSON sequence as a body input to tRESTClient
One Star

Re: How to make the tRestClient work?

Hi
Should these data go as a POST body ? if yes, set a body type to String and pass that JSON sequence as a body input to tRESTClient

Thanks sberyozkin,
No, these are not in the body, just parameters that pass along the URL.
Sixteen Stars

Re: How to make the tRestClient work?

You say it works in a URL. By that do you mean web browser? If so you should be using GET not POST. Try that. 
One Star

Re: How to make the tRestClient work?

You say it works in a URL. By that do you mean web browser? If so you should be using GET not POST. Try that. 

Thanks rhall,
Yes, that's is a URL that works. Whether I POST or GET, I'm getting the same error. I don't understand what the debug errors are telling me. I do know the 500 error occurs if I post a straight URL with no parameters like this "//democrm.ela.solutions/service/v4_1/rest.php?method=login". So it seems like the Talend component might have an issue not passing parameters? Do you recognize what the " at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)" means?

connecting to socket on port 3854
connected
Exception in component tRESTClient_1
javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.apache.cxf.jaxrs.client.AbstractClient.convertToWebApplicationException(AbstractClient.java:507)
    at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:895)
    at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:863)
    at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:426)
    at org.apache.cxf.jaxrs.client.WebClient.get(WebClient.java:609)
    at esb_test.copy_of_get_sessionkey_basic_rest_0_1.Copy_of_Get_SessionKey_Basic_Rest.tRESTClient_1Process(Copy_of_Get_SessionKey_Basic_Rest.java:750)
    at esb_test.copy_of_get_sessionkey_basic_rest_0_1.Copy_of_Get_SessionKey_Basic_Rest.runJobInTOS(Copy_of_Get_SessionKey_Basic_Rest.java:1143)
disconnected
    at esb_test.copy_of_get_sessionkey_basic_rest_0_1.Copy_of_Get_SessionKey_Basic_Rest.main(Copy_of_Get_SessionKey_Basic_Rest.java:1000)