Start a new topic

Example using curl to post file

Hi folks,

I'm trying to post a file to the Kinvey storage system with curl. This will be useful to us for automated testing and troubleshooting.

I'm following the documentation here:

Here's my scripts:

curl -H"Host:" -H"Authorization: Basic xxx" -H"Content-Type: application/json" -d@blob.json -X POST

where xxx is our auth header, base 64 encoded, and yyy is our app name.

blob.json contains:


"_filename" : "20090918_042809_TREES_500_1.jpg",

"size" :94522,

"mimeType" :"image/jpeg"


It wasn't clear to me what to put in the _acl property, so I skipped that (was that a mistake?)

This returns something like this:


where yyy is again our app name, and I've changed a few of the values of the query parameters.

I then try to PUT to the _uploadURL:

curl --verbose -H"Content-Length: 94522" -H"Host:" -H"Date: Tue, 31 Dec 2013 00:23:31 GMT" -d@[filename] -X PUT [valued from upload url above]

Based on this url, I have tried both with and without the expect header:

I get this output:

* About to connect() to port 80

* Trying connected

* Connected to ( port 80

> PUT [uploadurl string] HTTP/1.1

> User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5

> Accept: */*

> Content-Length: 94522

> Host:

> Date: Tue, 31 Dec 2013 00:43:31 GMT

> Content-Type: application/x-www-form-urlencoded

> Expect: 100-continue


And then it hangs.

I see the files created in the kinvey console, but I get a file not found when I try to download them:

"Firefox can't find the file at"

I have looked at this doc and seem to be following everything:

I also do it within 30 seconds (I think, I'm cutting and pasting pretty quickly) because I know the upload url expires.

Has anyone had success with curl and the REST api for uploading files? Is that _acl field important (seems weird if it is, because the console shows the file metadata, just not the file)?

Any other hints on how to troubleshoot this?

Thanks for your time.


Hey Dan,

I wanted to let you know we're looking into it. We're a bit light on engineers over the holiday season but we're back in full swing next week. Love your app, by the way!
From your output it looks like you are sending the Expect: 100-continue header. Did you try removing it, as the article suggests (by using -H "Expect:").

If it is hanging then somehow curl does not know how to handle the 100 Continue sent by the server, which is odd. I think I've run into this problem before but can't recall the solution. Try --data-binary instead of -d.

hi i am trying a similar post request to invoke a custom end point. the curl script i have written is like 

curl -H"Host:%host%" -H"Authorization:%auth%" -H"Content-type:application/json" -d '{"ip":"","id":"sdlkfjsdfi"}' -X POST

but getting an error saying error:unable to parse json in request. 

What can be done to resolve this issue.

Hi Sundesh,

For your curl request, you need to change "Content-type" header value to "text/plain" to get rid of the error.



Kinvey Support

Thanks wani, it did work.:-)

How do I set _acl and _kmd field from a curl request.?


You cannot modify _kmd as it is maintained automatically.

You can pass _acl object in the curl request body ( -d option) directly. This link should help with the body format.



Login or Signup to post a comment