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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
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

screenshot of tXMLMap
0683p000009MEsc.png 0683p000009MEsc.png
Anonymous
Not applicable
Author

Also, could you help me with this please?
I want to set an element from the json as an array. Can this be done?
Current payload:
here i want the alternateCurrencyCodes and addresses as the array elements.
Required payload:
"alternateCurrencyCodes":,
 "addresses":
}
Current settings in tXMLMap, but not working:


Is this possible?
Thank you.
0683p000009MEsh.png 0683p000009MEsm.png
Anonymous
Not applicable
Author

here i want the alternateCurrencyCodes and addresses as the array elements.

You can define both alternateCurrenrcyCodes and adresses as loop element, and set All in one attribute as true. see my screenshot.
0683p000009MEsr.png 
Best regards
Shong
Anonymous
Not applicable
Author

Hi, 
thanks! that did help. IS there any way of adding square brackets before/after the elements in the array?
Example:
"alternateCurrencyCodes": ,
 "addresses":
}
Anonymous
Not applicable
Author

It adds automatically the  square brackets before/after the elements in an array. see my screenshot
0683p000009MEsw.png

Shong
Anonymous
Not applicable
Author

Hi,
I cannot seem to get the square brackets in my payload.
Attaching my screenshots here. Am i doing something wrong?
0683p000009MEt1.png   
0683p000009MEt6.png
Anonymous
Not applicable
Author

Hi 
Which version are you using? I am using Talend Open Studio for ESB 5.5.1, if you are using an older version, try to upgrade your studio version and test it again.
Best regards
Shong
Anonymous
Not applicable
Author

Hello,
I was using Talend Open Studio for Data Integration 5.5.1. Tried with ESB,it worked!
I have another issue.
Currently this is what i get in the payload :
,
      "parentGroupId":"876",
      "agencyGroupId":"191",
      "locale":"en_NZ",
     "defaultCurrencyCode":"GBP",
      "addresses":
   }
]
This is for only one row in the tsv file that is one record.
How can i implement a PUT loop for multiple records in the tsv?
That is the put request will get a payload of multiple values like :

       
           "ids":
           {
               "BuySystem": "ProductIntegrationTest3",
               "PlanSystem": "31C"
           },
           "version": 7,
           "status": "Active",
           "name": "Test3",
           "shortName": "Test3",
           "mediaTypes":
           
           ],
           "defaultCurrencyCode": "GBP",
           "alternateCurrencyCodes":
           
               "EUR"
           ],
           "addresses":
           
               {
                   "type": "Media",
                   "addressLine1": "line 1",
                   "addressLine2": null,
                   "addressLine3": null,
                   "addressLine4": null,
                   "addressLine5": null,
                   "postCode": "postcode",
                   "addressId": "Integration Test"
               }
           ]
       },
       {
           "ids":
           {
               "BuySystem": "3",
               "PlanSystem": "9NH"
           },
           "version": 2,
           "status": "Active",
           "name": "RENAULT",
           "shortName": "RENAULT",
           "mediaTypes":
           
               "Online",
               "Print"
           ],
           "locale": "en_NZ",
           "defaultCurrencyCode": "GBP",
           "alternateCurrencyCodes":
           
               "EUR"
           ],
           "addresses":
           
               {
                   "type": "Financial",
                   "addressLine1": "addressLine1",
                   "addressLine2": "Line2",
                   "addressLine3": "Line3",
                   "addressLine4": null,
                   "addressLine5": null,
                   "postCode": "postCode",
                   "addressId": "333"
               },
               {
                   "type": "Media",
                   "addressLine1": "addressLine1",
                   "addressLine2": "Line2",
                   "addressLine3": "Line3",
                   "addressLine4": null,
                   "addressLine5": null,
                   "postCode": "postCode",
                   "addressId": "653"
               }
           ]
       }
   ]
How can this be implemented? Will i have to use tFlowToIterate_1 component joining it to tRestClient(Tried but not working) or some other component?Thank you.
Anonymous
Not applicable
Author

Hi..
I am trying to use txmlmap component with trestclient. I recieve the following error though I don't have any null values in the records: 
 "  Payload: Error 400: BMXAA4149E - null is not a valid organization. Specify a valid Organization value as defined in the Organization application. "
Can you please post a solution for this. I am sharing the screenshots with you
0683p000009MEtB.png 0683p000009MEoC.png
Thanks
Anjali