Six Stars

Add authentication/authorization in a REST request

Hi,
Can anybody let me know how I can add authentication parameters (username/password/domain) to a REST request?
I want to get data using a REST request. If I use the REST URL in Chrome, it works correctly showing me the correct response. But when the same URL is given in a tREST component then I get the following exception:
Exception in component tREST_1
com.sun.jersey.api.client.ClientHandlerException: java.net.SocketException: Software caused connection abort: recv failed
6 REPLIES
Moderator

Re: Add authentication/authorization in a REST request

Hi,
Have you tried to use tRestClient component 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.
Six Stars

Re: Add authentication/authorization in a REST request

I had a look at the tRESTClient in Help documentation. But there is nothing in it regarding how to add authentication/authorization details. Is there a link regarding the same?
Six Stars

Re: Add authentication/authorization in a REST request

Sorry, my shortsightedness did not let me see the authorization option.
I added the authorization details in the tRESTClient component in the job and executed the job.
But it is giving me the following exception:
Exception in component tRESTClient_1
javax.ws.rs.RedirectionException: HTTP 302 Found
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:504)
at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:897)
at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:865)
at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:428)
at org.apache.cxf.jaxrs.client.WebClient.get(WebClient.java:611)
at test_project.test_rest_0_1.Test_REST.tRESTClient_1Process(Test_REST.java:714)
at test_project.test_rest_0_1.Test_REST.runJobInTOS(Test_REST.java:1111)
at test_project.test_rest_0_1.Test_REST.main(Test_REST.java:968)
If I give the same URL that I have provided in the job in a web browser, it works fine. So any ideas why I am getting HTTP 302 status code?
One Star CEB
One Star

Re: Add authentication/authorization in a REST request

Hi,
You have find an solution for you issue ? i'm interesting if you have the answer Smiley Happy
One Star

Re: Add authentication/authorization in a REST request

Same problem for me, using header token also, any resolution??
Four Stars

Re: Add authentication/authorization in a REST request

I've encountered a similar issue with tRestClient in that it throws an exception when for HTTP Response code 303

For HTTP Response code 200 or 202, the tRestClient component works.  However it does not appear to handle HTTP Response code 303.