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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Error when setting up tRest with JSON

Hi
I am getting an error when attempting to add JSON to the http body field in the tRest component.
The JSON I am inserting into the http body field is:


"{  
   "action":"createOnly",
   "lookupField":"email",
   "partitionName":"name",
   "input":[  
      {  
         "email":"email@email1.com",
         "firstName":"Kataldar-1",
         "postalCode":"04828"
      },
      {  
         "email":"kjashaedd-2@klooblept.com",
         "firstName":"Kataldar-2",
         "postalCode":"04828"
      },
      {  
         "email":"kjashaedd-3@klooblept.com",
         "firstName":"Kataldar-3",
         "postalCode":"04828"
      }
   ]
}"

The errors I get are:


0683p000009MFaj.png


I can run the component ok when I use a content type of "application/x-www-form-urlencoded". Any idea what format this JSON needs to be in in order to be accepted, the JSON has been taken directly from the Marketo create leads example request.
Thanks

Labels (2)
1 Reply
Anonymous
Not applicable
Author

You have to escape the " within the json content and add + between the lines to get a clear java String.
"{  \n"
+ " \"action\":\"createOnly\",\n"
+ " \"lookupField\":\"email\",\n"
+ " \"partitionName\":\"name\",\n"
+ " \"input\":[ \n"
+ " { \n"
+ " \"email\":\"email@email1.com\",\n"
+ " \"firstName\":\"Kataldar-1\",\n"
+ " \"postalCode\":\"04828\"\n"
+ " },\n"
+ " { \n"
+ " \"email\":\"kjashaedd-2@klooblept.com\",\n"
+ " \"firstName\":\"Kataldar-2\",\n"
+ " \"postalCode\":\"04828\"\n"
+ " },\n"
+ " { \n"
+ " \"email\":\"kjashaedd-3@klooblept.com\",\n"
+ " \"firstName\":\"Kataldar-3\",\n"
+ " \"postalCode\":\"04828\"\n"
+ " }\n"
+ " ]\n"
+ "}"

It is a bit cumbersome but unfortunately Talend has not added here the same convenience as we have for SQL in the database components.