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

4 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?

1 Like

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

3 Likes