Omeka API - File upload - 403 -Invalid request. Exactly one file must be uploaded per request

Hello,

I’m trying to upload an image file through the API but i get a {“message”:“Invalid request. Exactly one file must be uploaded per request.”} or a 403 error.

From RESTClient i get a { “message”: “Invalid request. Exactly one file must be uploaded per request.”}

from the app that i try to build fiddler shows me a 403 Forbidden
You don’t have permission to access /api/files on this server.

POST http://archive.odigitria.net/api/files?key=be3e638cbd6518b8c56b330d144007425bd02cfa HTTP/1.1

Content-Type: multipart/form-data; boundary=E19zNvXGzXaLvS5C
Host: archive.odigitria.net
Content-Length: 263173
Expect: 100-continue

----E19zNvXGzXaLvS5C
Content-Disposition: form-data; name=“data”
{“item”: {“id”: 76}}
----E19zNvXGzXaLvS5C
Content-Disposition: form-data; name=“file”; filename="fullscreen11.jpg"
Content-Type: image/jpeg
Content-Encoding: base64

/9j/4SyRRXhpZgAASUkqAAgAAAADABoBBQABAAAAMgAAABsBBQABAAAAOgAAACgBAwABAAAA0WZ1Zb8N3pWT5QhtoopvvE1uYJoix8wY8sRuJ2EMqleP+c4ymN+9NY2z+n4qT2ak9mpLByKkKlwVqRqK9Ze9CPw6kR1NGE9Hq3pxmjEk6p7GrEA+pnu1OIrJqQz1qxFpNRz3pxFmvCe9IUNyT3qSplJqSV9RzUhlHFSXC1JDOVqQRZj2qQT5qQJqSKk9Uk5qT2TUnuTUhUjzUjEcI64qRlUAGaCksFqRaSXJ60guzmpBljUkbzUk+Yak95hqSC1SVNSeqT1SeqT1SeqSwxUhQwqSGYVIInNSRUnqk9Unqk9Unqk9Unqk9Unqk9Unqk9UlxUk7sVJ7dUkhxUlhIKEuJaigyE1JQsTUkZqCpapPbqUnfUnt9SQXNSVJJqSKkIiE1EdUxQkkYqSyLnrUjCLigihwKE//9k=
----E19zNvXGzXaLvS5C

Your multipart message doesn’t look quite right… If the boundary is declared as “E19…” then the actual boundaries in the message should look like --E19.., with two leading hyphens. You do often see extra hyphens, but any beyond two would have to be included in the declared boundary in the Content-Type.

It looks like you’re working off the example from the API docs as a template. That’s really just there for illustrative purposes. Whatever you’re using to make the request should be able to put together a multipart POST for you, so you don’t have to fool around with the boundaries and encoding of each part.

Seems that were some format errors at the POST body, except the missing – at the end of the final boundary and a missing newline in the middle.

Now the POST returns 201 but the image is not uploaded correct.

So i would like to ask if the image has to been converted in base64 or in binary or something else?

Thank you.

I don’t believe you can really use Content-Transfer-Encoding in an HTTP upload, it’s really more of an email header.

A standard multipart/form-data upload will just include the as-is binary of the file directly in its part, not a base64-encoded variant.