POST to rest API help

I am relatively new to Knime, and am having issues pulling data out of Sumo Logic via their REST API. I can do it successfully in python, but I’m having issues getting a POST workflow to work in KNIME.

API details can be found here

The API flow is I submit an initial POST request with a data payload and authenticate, the API responds with some data that includes a URL for my submitted Sumo query and a cookie that will be used for all additional requests. Once I get the URL back I continue to check the returned URL(using the cookie so I don’t get load balanced to a backend server that doesn’t have my submitted job) until the status is marked as complete. I then can start downloading the data, which typically requires paging.

So far I have:

"POST Request" --> "JSON To Table" 

Which works, and I can see the returned URL for checking my submitted job’s status, however I can’t figure out how to grab the cookie that is returned so that I can check the URL using that cookie.

How do I get the cookie from the initial POST Request so that I can use it to make an another POST Request using the URL that was returned from the 1st POST?

In the world of Python I would do the following:

rPOST = requests.post(SUMOurl, auth=(uname, passwd), data=json_data, headers=headers)
JobURL = str(json.loads(rPOST.text)[u’link’][u’href’])
CookieMonster = rPOST.cookies

Then later grab my data with:

rGET = requests.get(JobURL , auth=(uname, passwd), cookies=CookieMonster ))

How do I recreate that python code in a Knime workflow? Other than using a Python extension node to do it :slight_smile:

Hi Nicksandmann,

I’m not sure how this can be achieved with the POST nodes, but if you’re willing to give the Palladian nodes a try, there’s a very convenient way:

The HTTP Retriever has a dedicated output and input port for cookie information. This way, you can conveniently pass e.g. session-related cookies from request to request (consider the lower connection the :cookie: monster in your code snippet):

In case you haven’t downloaded the Palladian nodes yet, here’s the link to the download page on NodePit:

And in case you have any questions, do not hesitate to post in the Palladian sub-forum – we’re there to help!

– Philipp

2 Likes