Add authentication/authorization in a REST request

Eight 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
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.
Eight 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?
Eight 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??
Five 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.  

15TH OCTOBER, COUNTY HALL, LONDON

Join us at the Community Lounge.

Register Now

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch