Error uploading workflow group to Knime Server using REST API

Hi,
I am trying to upload a workflow group via the REST API.
The documentation at http://<knime_server_address>/knime/rest/v4/_profile/knime-server-doc-v4.xml
says that I can PUT the workflow-group by uploading a ZIP file. But when I call
http://<knime_server_address>/knime/rest/v4/repository/<workflow_group_path>:data
I get a HTTP 500 response with 1 line in the body saying:
The workflow group at ‘’ cannot be overwritten by a file

What am I doing wrong? I am using server Version 4.11.4

Thanks.
-Sankar

Hi Sankar,
http://<knime_server_address>/knime/rest/v4/repository/ points to the root of the repository, which you cannot overwrite. If you want to write a workflow group inside the root, then you need to pass that name. If the group should be called “Test”, then you can do a PUT request to http://<knime_server_address>/knime/rest/v4/repository/Test.
Kind regards,
Alexander

Sorry if my question wasn’t clear, here are the steps that I did:

  1. PUT to http://<knime_server_address>/knime/rest/v4/repository/Test without any body to create a workflow-group called Test. This step worked and I am able to see the folder on the server.
  2. PUT to http://<knime_server_address>/knime/rest/v4/repository/Test:data with the body being the .zip file contents to upload all the files for the workflow group. This 2nd call is what fails with HTTP 500 and the message “The workflow group at Test cannot be overwritten by a file”.

I used the following python code to PUT the zip file contents to the server.

with open(‘Zipped_file.zip’, ‘rb’) as data:
response = requests.put(upload_workflow_url, auth=(‘user’, ‘pass’), data=data)

Note: The zip file contents are:
Archive: Zipped_file.zip
Length Date Time Name
'--------- ---------- ----- ----
0 02-14-2021 11:07 Sales_Attr_MF_V3/workflowset.meta
4345 02-14-2021 11:07 Sales_Attr_MF_V3/Metainfo/Evaluation_Table.table
2704 02-14-2021 11:07 Sales_Attr_MF_V3/Metainfo/QA_Test_Thresholds.table
2753 02-14-2021 11:07 Sales_Attr_MF_V3/Metainfo/Modelling_Configuration.table
0 02-14-2021 11:07 Sales_Attr_MF_V3/Metainfo/workflowset.meta

The list is long but I have just shown the first part of the output from “unzip -l” to show the directory structure at the top-level.

I also tried sending the contents of the .zip file without doing the first PUT call (i.e. without pre-creating the workflow-group) but that ends up creating a file called Test with the .zip contents instead of a folder.

Finally, I tried sending the contents of the .zip file in the first PUT call itself (without :data) and got a HTTP 415 error saying “No data must be sent when creating workflow groups”.

Thanks.

Hi,
You won’t need to create the workflow group before the upload. I just tried the second request on my server and it worked fine. Did you maybe forget to set the Content-Type header to: application/vnd.knime.workflow-group+zip?
Kind regards,
Alexander

Yes, the Content-Type header was the issue. It works now. Thanks.

Sorry, I might have spoken too soon. I have a valid zip file (I confirmed it with unzip -l) and have the Content-Type set to ‘application/vnd.knime.workflow-group+zip’ but the response has a valid json but shows the class to be “Data” and not Workflow-group.
{
“_class”: “com.knime.enterprise.server.rest.api.v4.repository.ent.Data”,
@controls”: {

Is the content-type not being recognized. I have tried from a python program and from Postman with the same repsonse. What else could I be missing.

One more piece of info:

The server logs have the following line when I tried to upload:
19-Feb-2021 06:10:25.055 WARNING [http-nio-8080-exec-4] com.knime.enterprise.server.rest.impl.v4.repository.data.UploadImpl.extractUpload Upload of ‘Users/sankar/test_snowflake_conn_43’ by knimeadmin contained more than one entry in zip file, importing only ‘/knime/opt/knime_server/workflow_repository/temp/Upload from knimeadmin7557987215482435562/workflow.svg’.

Hi,
I believe the zip file must be “on top” of the workflow group folder, so that when you unzip it you get the actual folder and not the content of the workflow group.
Kind regards,
Alexander

Thanks, this was the issue. It works now.

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