Uploading pictures to a collection

Hey guys,

I am trying to create something like a gallery consumer. For that I want to write a admininterface, where you can upload pictures to cockpit. But I actually have no idea how. At this moment I am trying with postman.

How Do I upload a picture to the api? The collection has one field named picture, where the picture should be stored. Its type of “Picture”.

I saw in the documentation, that

{
"meta": {
    "title": {
        "type": "text",
        "label": "Title"
    }
}
}

this is expected by the api. But how am I gonna put my image in that json object? I tried base64 encoding my picture, but where do I put that? Do I even have to encode it?

Do you have some ideas for me?

Edit: I tried using /api/cockpit/addAssets but I only get this response here:

Greetings,
Lukas

Try it with files[] instead of files[0]. See also

That gives the same response. Edit: I am hosting it in xampp, if that helps.

I had a second look at your initial post. So you try to upload an image with meta data.

First: Are you sending additional json data in the body? If so, does the upload work without it?

If it works, then you can send the meta data as form data, too. See also:

Okay. Yeah first I tried adding pictures to a collection, which is not possible.

Now I am trying to add it as an asset. With the request shown above.

I am not submitting additional json data in the body. The request above is the only data I am submitting.