[API - curl] - Error on POST as draft

Dear everybody

I am trying to change the status of my form to draft by using the API with curl but the server return an error message : {"message":"Required parameter formId missing.","code":400.2,"details":{"field":"formId"}}

My curl command is like :
curl -X POST https://<SERVER_NAME>/v1/projects/<PROJECT_ID>/forms/<FORM_ID>/draft?ignoreWarnings=true -H "Authorization: Bearer <USER_TOKEN>"

I have controlled many time the name of form_id in the url and there is no problem. (if there was a problem here the error message is "Could not find the resource you were looking for.")
As well, if my form is in draft status (from the web interface) I can publish the form without problem with curl.

Strangely, changing my form status to draft is working with postman application... I really don't understand what's happen with curl...

ODK server version : v2023.3.0

Thanks in advance for the help

I found a solution, not ideal but working. I need to send the xls form files with the url request

The curl command need to be like this :
curl -X POST https://<SERVER_NAME>/v1/projects/<PROJECT_ID>/forms/<FORM_ID>/draft?ignoreWarnings=true -H "Authorization: Bearer <USER_TOKEN>" -H "Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" -H "X-XlsForm-FormId-Fallback: <FILE_NAME>.xlsx" --data-binary "@./<FILE_NAME>.xls"

I have another alternative which more corresponding to me !

Declare content-Length to 0 like this
curl -X POST https://<SERVER_NAME>/v1/projects/<PROJECT_ID>/forms/<FORM_ID>/draft?ignoreWarnings=true -H "Authorization: Bearer <USER_TOKEN>" -H "Content-Length: 0"

1 Like

Thank you for coming back and providing details about how you got it to work!