Moving this to the Sync Gateway category…
From what the REST API documentation says , the URL to post to should look a bit like this:
PUT /cookbook/LemonChicken/lcnote.txt?rev=1-78abf9a6508671ba8338e4ef6daa910a HTTP/1.1
yours looks something like this…
PUT /sync_srucc/9ef40c1d-dfac-4e41-a987-a23ckk25bc3198?=/tablet.png HTTP/1.1
Note the first one is an attachment to the document LemonChicken and is behind a slash, while yours seems to be an item itself.
Continuing the discussion from How to add attachments? :
Thanks - That makes a lot of sense…I’m afraid I’m still stuggling a bit, however, I’ve tried the Rest API with every combination I can think of…here’s the curl message and response:
teds-mbp:graphics Ted$ curl -vX PUT http://ec2-54-241-255-224.us-west-1.compute.amazonaws.com:4984/sync_srucc/9ef40c1d-dfac-4e41-a987-a23ckk25bc3198?=/tablet.png --data-binary @tablet.png -H “Content-Type: image/png”
Hostname was NOT found in DNS cache
Trying 54.241.255.224…
Connected to ec2-54-241-255-224.us-west-1.compute.amazonaws.com (54.241.255.224) port 4984 (#0 )
> PUT /sync_srucc/9ef40c1d-dfac-4e41-a987-a23ckk25bc3198?=/tablet.png HTTP/1.1
> User-Agent: curl/7.37.1
> Host: ec2-54-241-255-224.us-west-1.compute.amazonaws.com:4984
> Accept: /
> Content-Type: image/png
> Content-Length: 29527
> Expect: 100-continue
>
< HTTP/1.1 415 Unsupported Media Type
< Content-Type: application/json
Server Couchbase Sync Gateway/1.00 is not blacklisted
< Server: Couchbase Sync Gateway/1.00
< Date: Tue, 10 Feb 2015 17:59:29 GMT
< Content-Length: 76
HTTP error before end of send, stop sending
<
Closing connection 0
{“error”:“Unsupported Media Type”,“reason”:“Invalid content type image/png”}
teds-mbp:graphics Ted$
So I’m not sure if there’s a error above, I have a config setting wrong, or what…
Thx again
T
awesome - that was it…somehow this got added to the end of the document guid “?=”…thx for all your help!
Any idea how to PUT an image attachment using the REST API? How does it need to be encoded? I’m using fetch .