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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tRestClient post JSON body

Hi,

 

Here is my job :

 

0683p000009M4RO.png

I want to send a post request with a json body. I'm getting the json from a raw file. Here is my tMap :

 

0683p000009M45V.png

I saw that for a json it was the string field of the trestclient that was used.

But i don't understand, i still get nothing in the output body of tRestClient.

 

 If you need more information, just ask, i'll do my best to answer.

Thank you.

 

Labels (4)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Use tRest to include a POST body. You can just pass the row object into that body text field and it will pass it through.

View solution in original post

6 Replies
Anonymous
Not applicable
Author

Use tRest to include a POST body. You can just pass the row object into that body text field and it will pass it through.

Anonymous
Not applicable
Author

Thank you it's way more simple indeed.

 

Unfortunately, i still have an empty body response.

 

Here is my request body :

{
"request": "1",
"io_mode": "json",
"do_in": [
"{\"method\":\"Infos.getInfos\"",
"\"params\":[]}"
]
}

He's the syntax good ? It's maybe because of that.

 

Anonymous
Not applicable
Author

Have you made this request successfully in something other than Talend (e.g. Postman)? I usually try it there first to see of my syntax is correct.  Also, wouldn't hurt escaping all your double quotes.

Anonymous
Not applicable
Author

In JSON it was not working so i tried another format :

request=1&io_mode=json&do_in={"method":"Infos.getInfos","params":[]}

 

I wrote this in my tRest :

"request=1&io_mode=json&do_in={\"method\":\"Infos.getInfos\",\"params\":[]}"

 

As you can see i escaped all my double quotes.

But it's still not working.

Anonymous
Not applicable
Author

It's ok. I just forgot to change the content-type. I close the topic.

Lord-Vader
Contributor III
Contributor III

I know this was resolved but i am just adding for when someone has issues with this again. If you have your JSON already in a file then this is for you, but if you don't i suggest this post --> https://community.talend.com/s/feed/0D73p000004sQALCA2 (for tRestClient).

How:

  1. I get the JSON from tFileInputRaw as an Object in a column called "content"(default fot this component).
  2. I convert it to string in the tmap.(just like above original post)
  3. Then I map the content column to the string column in the tRestClient and not the body, for some reason its not via the body.
  4. Then i log the output and the error.

 

If everything is good it should work.

0695b00000huSADAA2.png 

Hope this helps someone.

Vader Out 💪.