One Star

Taking input from Jason file and Posting to Rest API using tRestCLient

Hi,
I have created a job where i am reading the data from a Jason file and trying to send it to tRestClient using POST method. The Response also i should get in the Jason File. However when i try to run the job its throwing error as Unhandled exception type DocumentException.
Attaching screenshots of the job and the error.
Please suggest how to resolve this error and get the output file.
Thanks in Advance,
Arpita
8 REPLIES
Twelve Stars

Re: Taking input from Jason file and Posting to Rest API using tRestCLient

please check screenshot - it missed
-----------
One Star

Re: Taking input from Jason file and Posting to Rest API using tRestCLient

Attaching the screenshots. Please let me know if its visible. I am able to view in myuploads.
Rest_Api.zip.zip
Twelve Stars

Re: Taking input from Jason file and Posting to Rest API using tRestCLient

did You try open this page by Your self? Smiley Happy it not hard - just reopen!
sometime it miss file - press edit and add again, than Submit
This Your pictures:
     
-----------
One Star

Re: Taking input from Jason file and Posting to Rest API using tRestCLient

Attaching as zip format.
Rest_Api.zip_20161117-0118.zip
Twelve Stars

Re: Taking input from Jason file and Posting to Rest API using tRestCLient

I think - You are use wrong component. tJSOONInput file - convert JSON to the flat structure 
but tRESTClient expect normally JSON as input, see some example how it work
Think You must or read json as single element with JSON structure, and name this column "body", or input between tInputJSONFile -> tWriteJSONField -> tRESTCleint
Depending from response You could use tExtractJSONFields
 
-----------
One Star

Re: Taking input from Jason file and Posting to Rest API using tRestCLient

Hi,
Thanks for your input. 
i tried using tInputJSONFile -> tWriteJSONField and i am getting the output in the form of two separate fields as string.
but when i try to change it to document it is throwing error.
inside my jason file i have 2 fields, username and password and both must be passed inside the body content of the tRESTClient.
Please suggest how to implement it.
Twelve Stars

Re: Taking input from Jason file and Posting to Rest API using tRestCLient

attach Your screenshot - as You can see from my - it work, so need to check how You prepare body
-----------
One Star

Re: Taking input from Jason file and Posting to Rest API using tRestCLient

Hi, 
Using tXMLMap i am able to pass the values into the body section of the tRestClient.
This is the first step where i am sending a POST request to get the authentication key.
In the second step, i am using a GET method and using the same authentication key recieved in the first step, however i am getting an error as 
: org.apache.cxf.phase.PhaseInterceptorChain - Interceptor for {<GET - URL>}tRESTClient has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.jaxrs.client.AbstractClient.doRunInterceptorChain(AbstractClient.java:635)
at org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:1071)
at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:878)
at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:852)
at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:410)
at org.apache.cxf.jaxrs.client.WebClient.get(WebClient.java:594)
at og_surface_ib.energent_api_rest_test_0_1.Energent_API_REST_TEST.tFileInputRaw_1Process(Energent_API_REST_TEST.java:3443)
at og_surface_ib.energent_api_rest_test_0_1.Energent_API_REST_TEST.tFileInputJSON_1Process(Energent_API_REST_TEST.java:2253)
at og_surface_ib.energent_api_rest_test_0_1.Energent_API_REST_TEST.runJobInTOS(Energent_API_REST_TEST.java:3930)
at og_surface_ib.energent_api_rest_test_0_1.Energent_API_REST_TEST.main(Energent_API_REST_TEST.java:3787)
Caused by: javax.net.ssl.SSLHandshakeException: SSLHandshakeException invoking <GET URL with Authorization Key>: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
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.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1347)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1331)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:632)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
... 11 more


Please advice how to resolve this issue.
Thanks,
Arpita