cancel
Showing results for 
Search instead for 
Did you mean: 

Upload Custom Model via REST API using curl

Upload Custom Model via REST API using curl

I tried to upload my custom model via REST API with the following code:

curl -X POST 'https://mohmlovpapp01.healthgrp.com.sg/api/v2/customModels/6384510809470eaf11538486/versions/'  -H 'Content-Type: multipart/form-data' -H 'Accept: application/json' -H 'Authorization: Bearer {access-token}' -F 'filePath=rd.pkl' -F 'files=@/home/pamunixadm3001/rd.pkl' -F 'baseEnvironmentId={EnvironmentId}'

 

However, it returns the error message:

{"message": "Invalid field data", "errors": {"files": "Each file must have a corresponding filePath. Supply the files as a form-data list of `file` objects. And supply the relative file paths as a form-data list of `filePath` strings"}}

 

How do I resolve this issue? Thank you

Labels (1)
0 Kudos
1 Reply

Hi!

As it is described in the documentation:

  • file - A file with code for a custom task or a custom model. For each file supplied as form data, you must have a corresponding filePath supplied that shows the relative location of the file. For example, you have two files: /home/username/custom-task/main.py and /home/username/custom-task/helpers/helper.py. When uploading these files, you would also need to include two filePath fields of, "main.py" and "helpers/helper.py". If the supplied file already exists at the supplied filePath, the old file is replaced by the new file.
  • filePath - The local path of the file being uploaded. See the file field explanation for more details.

So I guess your parameters are confused there. Try:
-F 'filePath=@/home/pamunixadm3001/' -F 'files=rd.pkl'

0 Kudos