Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
Labels (4)
6 Replies
Anonymous
Not applicable
Author

Hi,
Have you tried to use tRestClient component to see if it works?
Best regards
Sabrina
Anonymous
Not applicable
Author

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?
Anonymous
Not applicable
Author

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?
CEB1
Contributor
Contributor

Hi,
You have find an solution for you issue ? i'm interesting if you have the answer 0683p000009MACn.png
Anonymous
Not applicable
Author

Same problem for me, using header token also, any resolution??
akelly
Contributor
Contributor

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.