Howto use WF-credentials in conjunction with invoking a WF via server REST API

#1

I'd like to invoke a workflow on the KNIME server via the server's REST API. The workflow uses the wf-credentials mechanism to connect to some DB. When invoking or scheduling the WF directly on the server I am asked to enter the required WF credentials and the WF executes successfully.

Is it possible to pass the necessary WF credentials via REST call to be able to invoke such a WF via the server's REST API?

Regards,

Markus

0 Likes

#2

The REST API doesn't support workflow credentials or variables. You have to use explicit quickform input nodes, e.g. the Credentials Input node.

0 Likes

#3

2.5 years later does the API support workflow credentials?

0 Likes

#4

No. And it never will. Workflow variables and credentials are deprecated. Use dedicated Input/Configuration nodes instead.

0 Likes

#5

Sorry, I’ve long forgotten about the workflow credentials and talking the credentials input node. I couldn’t get to mimic entering password in the window that pops up after clicking on execute.

How can include the credentials in the API call? I tried a few things, but none of them worked as my workflow was idle.

0 Likes

#6

You can add Credentials Configuration node, which allows you to provide credentials in execution dialog under “Configuration options” tab.

0 Likes

#7

I’ve figured it out by reading the examples and some trial and error. Sharing python code for reference for others.

import requests

url = "https://<server>:8443/knime/rest/v4/repository/<path>:execution?reset=true&timeout=-1"

payload = "{\"credentials-input\": {\"username\": \"******\", \"password\": \"**********\"}}"
headers = {
  'Accept': 'application/vnd.mason+json',
  'Content-Type': 'application/json',
  'Authorization': 'Basic ********************'
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.text.encode('utf8'))
0 Likes