Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I need your help to design the talend Job where i need to invoke rest api as below requirement:
1.
URL: https://pcacccess-stage.run.asv-pr.abbcsdas/externalapps/authenticate
Media Type: application/json
POST Data:
{
"clientId": "prasoon",
"clientKey": "2fcc99fb6d9d41978afd7kladfastes "
}
Expected response (token value will be different each time) –
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Length: 135
Content-Type: application/json;charset=UTF-8
Date: Thu, 09 Nov 2017 15:39:01 GMT
Expires: 0
Pragma: no-cache
Server: Apache
Strict-Transport-Security:
{
"success" : true,
"data" : "dasdjfasjdf-nasis018393-asdf",
"errors" : [ ],
"warnings" : [ ],
"infoMessages" : [ ]
}
How can i achieve this?
Is there any way i can test this url with cilent id and key,sorry i am new to this kind of application design.
Regards
PK
I think this past post might help. Take a look at how they did it.
Hi,
Thanks for your reply, but i dont have authorization token , but i have client id and key. When i put Client Id and key in tRest component, it fails with error.
I believe this should be your POST data.....
"{ \"clientId\": \"prasoon\", \"clientKey\": \"2fcc99fb6d9d41978afd7kladfastes\" }"
You don't need to follow the authentication stuff. Your service sounds a lot easier, but the general build should be the same
Hi,
Ok, i am doing what is suggested, please find attached screenshot. But getting below error:
Exception in component tREST_1 com.sun.jersey.api.client.ClientHandlerException: java.net.UnknownHostException: pcaccesscontrol-stag at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:131) at com.sun.jersey.api.client.Client.handle(Client.java:616) at com.sun.jersey.api.client.WebResource.handle(WebResource.java:559) at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:72) at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:502) at data_archival.app_rest_api_0_1.app_rest_api.tREST_1Process(app_rest_api.java:1000) at data_archival.app_rest_api_0_1.app_rest_api.runJobInTOS(app_rest_api.java:5223) at data_archival.app_rest_api_0_1.app_rest_api.main(app_rest_api.java:5037) 2017-11-10 15:48:57 [FATAL] (main): data_archival.app_rest_api_0_1.app_rest_api - tREST_1 java.net.UnknownHostException: pcaccesscontrol-stage.run.asv-pr.ice.predix.io Caused by: java.net.UnknownHostException: pcaccesscontrol-stage.run.asv-pr.ice.predix.io at java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at sun.security.ssl.SSLSocketImpl.connect(Unknown Source) at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source) at sun.net.NetworkClient.doConnect(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source) at sun.net.www.protocol.https.HttpsClient.New(Unknown Source) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler$1$1.getOutputStream(URLConnectionClientHandler.java:203) at com.sun.jersey.api.client.CommittingOutputStream.commitWrite(CommittingOutputStream.java:117) at com.sun.jersey.api.client.CommittingOutputStream.write(CommittingOutputStream.java:89) at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source) at sun.nio.cs.StreamEncoder.implFlushBuffer(Unknown Source) at sun.nio.cs.StreamEncoder.implFlush(Unknown Source) at sun.nio.cs.StreamEncoder.flush(Unknown Source) at java.io.OutputStreamWriter.flush(Unknown Source) at java.io.BufferedWriter.flush(Unknown Source) at com.sun.jersey.core.util.ReaderWriter.writeToAsString(ReaderWriter.java:191) at com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider.writeToAsString(AbstractMessageReaderWriterProvider.java:128) at com.sun.jersey.core.impl.provider.entity.StringProvider.writeTo(StringProvider.java:88) at com.sun.jersey.core.impl.provider.entity.StringProvider.writeTo(StringProvider.java:58) at com.sun.jersey.api.client.TerminatingClientHandler.writeRequestEntity(TerminatingClientHandler.java:305) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:182) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:129) ... 7 more
It looks like your URL is wrong.....
com.sun.jersey.api.client.ClientHandlerException: java.net.UnknownHostException: pcaccesscontrol-stag
Should that not be .....
pcaccesscontrol-stage
Sorry, some of the error part was removed.
Pasting error again:
Exception in component tREST_1 com.sun.jersey.api.client.ClientHandlerException: java.net.UnknownHostException: pcaccesscontrol-stage.run.asv-pr.ice.predix.io at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:131) at com.sun.jersey.api.client.Client.handle(Client.java:616) at com.sun.jersey.api.client.WebResource.handle(WebResource.java:559) at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:72) at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:502) at data_archival.app_rest_api_0_1.app_rest_api.tREST_1Process(app_rest_api.java:1000) at data_archival.app_rest_api_0_1.app_rest_api.runJobInTOS(app_rest_api.java:5223) at data_archival.app_rest_api_0_1.app_rest_api.main(app_rest_api.java:5037) 2017-11-10 15:48:57 [FATAL] (main): data_archival.app_rest_api_0_1.app_rest_api - tREST_1 java.net.UnknownHostException: pcaccesscontrol-stage.run.asv-pr.ice.predix.io Caused by: java.net.UnknownHostException: pcaccesscontrol-stage.run.asv-pr.ice.predix.io at java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at sun.security.ssl.SSLSocketImpl.connect(Unknown Source) at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source) at sun.net.NetworkClient.doConnect(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source) at sun.net.www.protocol.https.HttpsClient.New(Unknown Source) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler$1$1.getOutputStream(URLConnectionClientHandler.java:203) at com.sun.jersey.api.client.CommittingOutputStream.commitWrite(CommittingOutputStream.java:117) at com.sun.jersey.api.client.CommittingOutputStream.write(CommittingOutputStream.java:89) at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source) at sun.nio.cs.StreamEncoder.implFlushBuffer(Unknown Source) at sun.nio.cs.StreamEncoder.implFlush(Unknown Source) at sun.nio.cs.StreamEncoder.flush(Unknown Source) at java.io.OutputStreamWriter.flush(Unknown Source) at java.io.BufferedWriter.flush(Unknown Source) at com.sun.jersey.core.util.ReaderWriter.writeToAsString(ReaderWriter.java:191) at com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider.writeToAsString(AbstractMessageReaderWriterProvider.java:128) at com.sun.jersey.core.impl.provider.entity.StringProvider.writeTo(StringProvider.java:88) at com.sun.jersey.core.impl.provider.entity.StringProvider.writeTo(StringProvider.java:58) at com.sun.jersey.api.client.TerminatingClientHandler.writeRequestEntity(TerminatingClientHandler.java:305) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:182) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:129) ... 7 more
You should be able to get some sort of response by using the URL in a web browser. It will likely be an error, but it will be a response....if you can communicate with that server. Can you test that? If you cannot communicate with a web browser (which is what I suspect), you are missing a part of the puzzle.
Hi,
I am getting below response.
Is your browser using a proxy server? If so, you may need to use the tSetProxy to resolve this. It looks like you can connect with your browser, but not with Talend Studio. This is often due to proxy issues