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

JSON Body for POST Method in tFileFetch Component

Hi there, 

 

I've been looking for an answer but the 2 topics I found had no solution.

So here is the problem :

 

I want to get a cookie session (with the tFileFetch comp.) from a web service to use it (the cookie session id) in a tRest component. The thing is there is no "Body HTTP" in the tFileFetch component where I could write my JSON, and when I use the parameter to write login and password I get an 400 error bad request, I really need to put my json into a Body http.

 

thanks

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I found out a solution, thanks a lot for your help, I finally used a tJavaRow (tMap work also) -> tRestClient -> and used ((java.util.Map<String,java.util.List<String>>)globalMap.get("tRESTClient_1_HEADERS")).get("Set-Cookie").get(0).toString() in the second tRest once I'm connected.

 

Thanks

View solution in original post

4 Replies
nfz11
Creator III
Creator III

Why are you using tFileFetch to access the first web service?  Are you downloading a file, uploading a file, or both?  You can't specify the whole body of a POST request in tFileFetch as a string of JSON or otherwise.  The only time I am POSTing to a tFileFetch with JSON is when I am uploading a file and other parameters are needed.  I can use key/value parameters with a Content-type of application/x-www-form-urlencoded and this particular web service accepts them.

 

Are you sure you are putting your authentication credentials in the correct place in tFileFetch?  They could go in the 'Headers' section or the 'Advanced settings -> need authorization' section.  A 400 error is a bad request, most web services will return a 401 if authentication or authorization failed.  Make sure that you can access your web service outside of Talend in another environment such as Postman.

 

If you are not downloading or uploading files then consider using a tRestClient where you can specify the JSON body in the 'string' variable.

Anonymous
Not applicable
Author

Yes I can access to it in postman, and what I wanted to say, I need to GET what's call in postman in the "temporary header" -> JSESSIONID, which is temporary.

 

And I need to put a JSON in the body with a POST method. I can't use the need authorization section because I have other field to put in the body.

 

The main problem is how to get the cookie (JSESSIONID) when I need to put a string of JSON in the body to use my Web Service.

 

Sorry my english is not very well, I hope you'll understand everything clearly, thanks

Anonymous
Not applicable
Author

I found out a solution, thanks a lot for your help, I finally used a tJavaRow (tMap work also) -> tRestClient -> and used ((java.util.Map<String,java.util.List<String>>)globalMap.get("tRESTClient_1_HEADERS")).get("Set-Cookie").get(0).toString() in the second tRest once I'm connected.

 

Thanks

nfz11
Creator III
Creator III

Great, I am glad you figured it out.  Please select one or more answers as solutions so this topic gets marked as solved.