post API call using Knime nodes

I want to make an API call using KNIME. I have the code which is working fine in Postman but I am unable to replicate it in KNIME.
I am not so proficient with JAVA or json so can anyone please guide me how to proceed with KNIME post node or palledian http nodes?

here is the sample code:

curl -X POST https://xxxxxxxxxxxxx -H “accept: application/json” -H “Authorization: Basic NjA4xxxxYjkxZyupnbmnnbvccuiiknmnbmnbWEyMjk5ODIwNGY1NWRmMjczOnlIeUhhRGU4eVp5QWViZW5l==” -H “Content-Type: application/json” -d “{"name":"TEST_APP","owner_ref":"XYZ","from":"09239988823","to":"0092819804","auto_record":false,"action_on_connect":{"play":{"text":" Hi XYZ , Welcome to the world of market place . ","language":"en-US","voice":"Male"}}}”

Hi @Anurag,

this would be a task for the Post Request Node - the URL https://xxxxxxxxxxxxx goes in the “Connection setting”, the headers (starting with -H in your request) in the “Request Headers” Tab like so:

and the JSON payload, i.e. string after -d, goes in the “Request Body” tab.

What will come back is a JSON you could e.g. parse with the JSON Path Node (See its description for how to do this in detail).

Please let me know if that helps or if you need further hints!
Best Regards, Lukas

6 Likes

@LukasS Thanks a ton man! It worked!

Just one more query, I wanted to make the request body dynamic. Like for eg: I have telephone number in my request body but I dont want it to be constant. I want to take calling numbers from a table/database and then trigger an API call for each telephone number.

Is this possible in KNIME workflow?

2 Likes

Hey @Anurag,

glad to hear! Of course this is possible :slight_smile: I usually do this by preparing a table with the information I want to send with the Post Request and then use the Table to JSON Node - in the Request Body tab you don’t enter the information statically, but tell the POST Request Node to use the column with the just created JSON Payload.

Have fun!
Lukas

4 Likes

Hi, thanks for the above.
I am aiming to build similar solution, my payload is huge XML. What is the best way to go ahead? Pls can you help

XML
Send request and receive response
Convert to excel

Thanks
Murali

Hi Murali,

you could use

Optionally, you can use the Continental Nodes to nicely format the Excel file (best check out the example as described in the link).

Hope that helps!
Lukas

HI , I AM having a doubt regarding to send a excel file in post request node to 3 rd party servers,
how to do and how it will be , could you pls make us a way…

Hi @rohithsidagam and welcome to the forum.

Have you checked Lukas’ links to the KNIME Hub above for examples on how to use the nodes? What have you tried so far?

If you upload your workflow and provide more detail about where you’re stuck, you are much more likely to get effective help.

hi scott ,
thanks for the help…, As i am new to knime i dint found about the post request node could you please help me out any description or sample video

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.