We have a model deployed as a service. Main reason behind doing this is to be able to expose the model/workflow as REST API so that we can send variables from an external program (in table or json format) to the model in knime. Knime model will provide the prediction and we send this back to the external program again via REST API.
The problem we have now is that while our workflow ( with container inputs/outputs) deployment was successful, we couldn’t find the corresponding REST API for the external program to connect to. Are we missing any steps here? How can we find the API definition of our workflow?
I tried following The KNIME Server REST API | KNIME
Hi Kavya,
The blog post you linked is for the KNIME Server REST API, which is our old product. For Hub, when you have created a Service deployment, you can see it in the deployment list for the workflow. Here, click on the three small dots on the right side of the table entry and click “open”. This should open the OpenAPI documentation for the service endpoint in another browser tab.
Kind regards,
Alexander
Hi Alexander,
Thanks for your quick reply.Do you have additional documentation or videos for this please?
After clicking the 3 dots, it opened deployment page which has Jobs and Execution but im still not clear on how to get a api url that i can use to send a request and receive response.
For example, In a simple case, if i make api call to https://jsonplaceholder.typicode.com/posts/ and send a json-request with id and userid, i can request a response of title.
My expectation with knime workflow is i should be able to send var1,var2 as json-request to a api ( that we deployed) and receive var3 as response. Is this achievable?
“json-input” is the name you specified for the input in the Container Input (JSON) node.
I hope this helps! Let me know if you need anything else.
Kind regards,
Alexander
Thanks, im able to view my deployment execution in json format now. However, im not clear about Container Input(JSON) node configuration, Should i just mention the json in above format with arbitrary values? And then invoke the restapi url from external app (or postman or curl for testing) and send var1 and var2 values?
Hi,
Yes, what you configure in the container input is only for designing the workflow and being able to configure the following nodes in the absence of “real” input from a REST call.
Kind regards
Alexander
Thanks for your help so far. Im able to configure container input/output successfully. Since im not using data app and will be accessing the rest api from an external app(without knime user), is there a way to provide access to everyone/public or i should pass auth info as part of request?
Hi,
As of now, you will need to pass credentials to run the workflow. I think for one of the next releases (maybe even 1.9) there will be the option to create shareable links to REST and DataApp deployments. Those links won’t need any additional authentication, it is baked into the URL. But for now, you need to use an application password and pass it as basic auth in the Authorization header.
Kind regards,
Alexander
Thanks for the clarification. While my json-request is sent successfully (status 200) , i’m still getting the output based on the default input json config i setup in the Container Input (JSON) of my deployed workflow. Is there any way to confirm if the REST API did receive the request with new inputs parameters i sent.
If i understood the flow correctly , when we invoke the deployed workflow api with new parameters, the deployed worklfow should re-execute with new input parameters and provide a new output(REST API shouldnt change).Is my understanding correct?
Hi,
This looks correct. However, you should check the job state that is also returned by the REST API. Is it EXECUTION_FINISHED? If not, check the node_messages key in the JSON. Does it contain any error messages? If the workflow does not run successfully, the default values of the Container Output are returned.
Kind regards,
Alexander
Looks like there was a warning message with execution that made the workflow non executable but also didnt return any error messages as part of node_messages key. I looked into the full response and am able to correct the warning and the subsequent requests are successfully executed. Thank you so much for your guidance!