Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Parse data from tsv file to json and use tRestClient to create record

Hi,
I have been trying to use the tRESTClient component to create/update data into the database.
Also, the headers being acknowledged but the payload is shown as null i.e {} .
I am attaching my job design here.
Could there possibly be some error in the flow of components? as the payload is not getting rendered in the response-code?
ID: 1
Address: http://.....
Http-Method: PUT
Content-Type: application/json
Headers: {Content-Type=, Accept=, PREAUTH_USER_ID=}
Payload: {}            //// why so????
--------------------------------------
Sep 08, 2014 8:41:57 PM org.apache.cxf.interceptor.LoggingInInterceptor
INFO: Inbound Message
----------------------------
ID: 1
Response-Code: 400
Encoding: UTF-8
Content-Type: application/json;charset=UTF-8
Headers: {connection=, Content-Length=, content-type=, Date=, Server=, Set-Cookie=}
Payload: {"id":"IE-1410189116899","errors":,"message":"Expecting Accept=application/vnd.......mdm-v1+json"}]}
-----------------------
Exception in component tRESTClient_1
javax.ws.rs.BadRequestException
    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:463)
    at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:881)
    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.put(WebClient.java:474)
    at demotraining.test_put_0_1.test_Put.tWriteJSONField_1_InProcess(zany_Put.java:2778)
    at demotraining.test_put_0_1.test_Put$1ThreadXMLField_tWriteJSONField_1_Out.run(test_Put.java:1078)
Labels (6)
18 Replies
Anonymous
Not applicable
Author

my job design is :
TSV file(tFileInputDelimited_1)------tMap_1------tWriteJSONField_1-------tXMLMap_1-------tRESTClient_1(Error here)
Please help!!!!
Anonymous
Not applicable
Author

Hi 
Can you please upload some screenshots of tXMLMap and tRestClient componnents' settings?
Best regards
Shong
Anonymous
Not applicable
Author

Here,


0683p000009MEsI.png 0683p000009MEsN.png
 I am a bit confused between the body(Document datatype) column and the string(String datatype) column in tXMLMap. Are the component settings correct? Thank you.
Anonymous
Not applicable
Author

Hi 
You don't need a  tWriteJSONField_1 to write a json string, if you want to pass a request with json format to the rest webservice, just need to select Content Type and Accept Type as Json on tRestClient componnet and define the document in tXMLMap. Please my screenshots:
0683p000009MErq.png 0683p000009MEsS.png


Best regards
Shong
Anonymous
Not applicable
Author

Hi, 
After removing tWriteJSONField it still doesnt seem to be working at my end.
Attaching screen shots here :
Sep 10, 2014 3:46:26 PM org.apache.cxf.interceptor.LoggingOutInterceptor
INFO: Outbound Message
---------------------------
ID: 1
Address: ......
Http-Method: PUT
Content-Type: application/json
Headers: {Content-Type=, Accept=, PREAUTH_USER_ID=}
Payload: {}
--------------------------------------
Sep 10, 2014 3:46:27 PM org.apache.cxf.interceptor.LoggingInInterceptor
INFO: Inbound Message
----------------------------
ID: 1
Response-Code: 400
Encoding: UTF-8
Content-Type: application/json;charset=UTF-8
Headers: {connection=, Content-Length=, content-type=, Date=, Server=, Set-Cookie=}
Payload: {"id":"IE-1410344187613","errors":,"message":"Expecting Accept=application/......-v1+json"}]}
--------------------------------------
Exception in component tRESTClient_1
javax.ws.rs.BadRequestException
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:463)
at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:881)
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.put(WebClient.java:474)
at demotraining.zany_put_0_1.zany_Put.tFileInputDelimited_1Process(zany_Put.java:1849)
at demotraining.zany_put_0_1.zany_Put.runJobInTOS(zany_Put.java:2327)
at demotraining.zany_put_0_1.zany_Put.main(zany_Put.java:2186)
Anonymous
Not applicable
Author

here,
0683p000009MElO.png 0683p000009MEsX.png
Anonymous
Not applicable
Author

Hi,
Could there possibly be some error in the Accept header?
Payload: {"id":"IE-1410344187613","errors":,"message":"Expecting Accept=application/......-v1+json"}]}
But the same headers are working fine when i call the Put HttpMethod from a Rest Client API(Data does get saved in the database). So i am not sure why I am encountering this error in Talend.
Thank you.
Anonymous
Not applicable
Author

Hi 
Http-Method: PUT
Content-Type: application/json
Headers: {Content-Type=, Accept=, PREAUTH_USER_ID=}
Payload: {}

The palyload is still empty, have you defined the document tree on tXMLMap? Can you please upload a screenshot of tXMLMap component?

Best regards
Shong
Anonymous
Not applicable
Author

The payload is coming fine now, after removing the tWriteJSONField component