Talend Connect
Virtual Summit
JOIN US!
And visit the Customer
& Community Lounge.
May 27-28, wherever you are.

Add authentication/authorization in a REST request

Highlighted
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
Highlighted
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.
Highlighted
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?
Highlighted
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?
Highlighted
One Star
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
Highlighted
One Star

Re: Add authentication/authorization in a REST request

Same problem for me, using header token also, any resolution??
Highlighted
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.  

2019 GARTNER 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

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog