How to Access API using Knime Platform

Hi Team,

Can anyone help me how to access the Knime API nodes to Get information

Below is the Python version
URL # (https://ashok.aa.abc.people/api.php)

username = input(“u:”).encode(“ascii”)
password = getpass(“p:”).encode(“ascii”)

headers = {‘Content-Type’: ‘application/x-www-form-urlencoded’}

data = {“fields”:“asset_id,hostname,dns_domain,model,os_revision,team,status,Silo,Client,main_appli,Trigrams,Usage,GEO,team,team_in_charge”,
“filterlist”: “name”,
“list”: ServerName,
“format”: “json”,
“jsonKey”: [None]}

response =requests.post(‘https://ashok.aa.abc.people/api.php’,
headers=headers,
data=data,
auth=HTTPBasicAuth(username, password))

content = response.json()

I’d recommend to use a Python Script node to implement this.

As far as I know requests library comes with the default bundled environment with KNIME. That way you can copy the script as it is above.

You can just output the result e.g. via table and the parse the JSON from there using e.g. JSON Path node.

There’s Get Request node, however it is a bit limited when it comes to passing in that data object as far as I know.

1 Like

Is there a way without using python scrpit node

I now noticed you are actually using POST request.

Post request node can handle data submitted as part of body:

You can set up headers, body (your data object) and authentication in the tabs highlighted above.

There’s also an example on the knime hub on how to make a post request (in the example to a KNIME REST Service) - but think that should help get you started in setting up the node for your requirements.

2 Likes

Still facing issues
I am getting error code 407
401

Well 407 / 401 means auth failed - have you provided credentials in Authentication tab?

It’s a bit guessing now without more details provided from your end as to what you have tried etc. Maybe you can share more information.

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