CloudKit web services bad request when uploading asset

The steps to set asset values using Cloudkit Web services are:


  1. Request URLs for uploading asset data.
  2. Upload the asset data.
  3. Set the asset fields in records to the uploaded data.



I am getting the URL from step 1.

Then I am supposed to upload my asset using the given url ($[ASSET_UPLOAD_URL])

The Cloudkit reference document gives a curl command as an example:

curl -X POST $[ASSET_UPLOAD_URL] -d@[ASSET_FILE]


The problem is that when I am using this command in the Terminal, I have a "bad request" as a response.


But If I use the same command without the asset file, it kind of succeed with the following answer:

{"singleFile":{"size":0,"fileChecksum":"AW2cWT2PxzWixMKuuNMTHJ8CJ3sH"}}


Has anyone manage to send assets using the Cloudkit web services ?

Replies

Found the problem.

You still have to add the following header in your POST request:

X-Apple-CloudKit-Request-ISO8601Date

The signature and key-id headers which are used for other requests do not seem necessary for these upload request.


Actually I can make it works without this header. My Content-Type was wrong. It was text although I send binary.

how are you executing the curl command within xcode?