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: 
idembel2
Creator
Creator

MAKE API CALL

Hi All,

In my job i used tHttpRequest component to make request on API

For GET or POST method, i configure my component like bellow by reading parameters from a file.

0683p000009Lrzd.png

Now i need to make PUT method, and this method is not supported by tHttpRequest component.

Like solution, i try tRest component to solve issue.

 

My problem now is how to read my file and put it in a global variable then call it in the field "Corps HTTP" of component tRest to make my request

 

Thank you for help

Labels (1)
1 Solution

Accepted Solutions
idembel2
Creator
Creator
Author

Hi rhall_2_0,

 

I didn't test your solution because i produce my json with tFileoutputJson component which create automatically a json file.

 

But to solve this issue, after creating a json with tFileoutputjson component, i read the the same file with a routine in a tjava component.

This routine read all file's data and put it in a string (globla variable) that i call in tRest component.

 

Thank all for help,

View solution in original post

2 Replies
Anonymous
Not applicable

The tRest is actually simpler and doesn't require that you write to a file. Simply produce your JSON in the same way as before, but do not write it to a file. Connect your component that outputs your JSON to a String, to a tFlowToIterate component. This component will allow you to connect your tRest using an Iterate link. It will also add your value to the globalMap. If the "row" connecting to your tFlowToIterate is called "row1" and your JSON column is called "json", the globalMap will be referenced using this code....

 

((String)globalMap.get("row1.json"))

Simply put that in your HTTP Body field WITHOUT surrounding quotes.

 

You may need to tweak some of your headers. Take a look here for that (https://help.talend.com/reader/iYcvdknuprDzYycT3WRU8w/_N82Hv0ivAnxD69EWaC5rA)

 

 

idembel2
Creator
Creator
Author

Hi rhall_2_0,

 

I didn't test your solution because i produce my json with tFileoutputJson component which create automatically a json file.

 

But to solve this issue, after creating a json with tFileoutputjson component, i read the the same file with a routine in a tjava component.

This routine read all file's data and put it in a string (globla variable) that i call in tRest component.

 

Thank all for help,