Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Serendipity
Contributor II
Contributor II

JSON request payload not sending with tRESTClient

Hello everyone,

I'm new to Talend, and I'm working through some tutorials as I try to work on a couple projects. I'm currently attempting to send a POST request to an API with a JSON body request payload. I've seen several threads here on this and I've tried suggestions from all, but I'm still not getting the payload to actually send with the request, my response is always the response of a request with no payload. No errors, the responses are completing, but I can't seem to get the payload included.

My end goal is that I'm going to be using the results of another API request that I have working to supply the JSON value as a variable, and loop through a list to pull all the datasets, so, currently I have the values I need to build the JSON from in a CSV.

I've tried tWriteJSON, tMAP, and tXMLMap to try and build the JSON, and I can get a proper output from all three, but none of them get sent with the request.

So my current iteration is using tWriteJSON Field:

0695b00000HsLoXAAV.png

from tLogRow6 I have this:

.-----------------------.

|    tLogRow_6    |

|=---------------------=|

|output         |

|=---------------------=|

|{"rootTag":{"id":1082}}|

'-----------------------'

The piece I'm trying to send with the request is:

{"id":1082}

On the tRestClient, I have method, content, accept types set to JSON. I have the option to Drop JSON Request Root checked.

I've seen some mentions that it needs to come in as a "Document" type, and I've tried setting the schema of the tWriteJSON to Document but get an error cannot convert from String to Document. IF I put a tConvertType in there after the tWriteJSON, just using the schema I get a null output or an error on line 1 Content is not allowed in prolog.

Any guidance is appreciated!

Labels (5)
1 Solution

Accepted Solutions
Serendipity
Contributor II
Contributor II
Author

I got this figured out, thought this might help someone else along the way. This article helped, but as a new Talend user, it took a bit of cross referencing to understand how to build the actual XML output properly

https://wynandbooysen.com/posts/2019-07-08-talend-tip-posting-json-with-trestclient/

 

0695b00000HsMoEAAV.pngI missed that in the tXMLMap you have to create the body document element in the lower right section, then connect the data elements into the tree as subnodes.

0695b00000HsMoJAAV.png 

I will also say it appears that the output going into tRest needs to be named "body".

 

Hope this helps someone, I'm looking for good training resources, as I'm just jumping in trying to learn as I go based on my use of other tools.

View solution in original post

1 Reply
Serendipity
Contributor II
Contributor II
Author

I got this figured out, thought this might help someone else along the way. This article helped, but as a new Talend user, it took a bit of cross referencing to understand how to build the actual XML output properly

https://wynandbooysen.com/posts/2019-07-08-talend-tip-posting-json-with-trestclient/

 

0695b00000HsMoEAAV.pngI missed that in the tXMLMap you have to create the body document element in the lower right section, then connect the data elements into the tree as subnodes.

0695b00000HsMoJAAV.png 

I will also say it appears that the output going into tRest needs to be named "body".

 

Hope this helps someone, I'm looking for good training resources, as I'm just jumping in trying to learn as I go based on my use of other tools.