Add Images to Collections via API?

Is it possible to add images to a collection via the API?

If so can someone give me some pointers as the documentation seems a little sparse?

@rjkmelb, never tried but in theory, it should be. You may need probably the following:

  1. Create asset using the api and get the asset details (I can see an addAssets function in the RestApi)
  2. Create your collection entry using the api and using the asset from previous step

Hope that helps and let us know on the results

This is an old post, but unfortunately the answer does not help me solve this issue. I do see the addAssets function but have no clue how to invoke it.

Can anyone shed some more light on how to add (as in upload) images and associate them with collection items?

Are you trying to invoke it programmatically or via API?

If via API you need to send a multipart post, e.g.:

And you receive an array of assets.

I am invoking the API and this additional information helps a lot :slightly_smiling_face: Thank you very much!

Still took me some time, due to lack of experience and sloppy coding, but I finally got it to work. The thing that took the most time, is an issue when using fetch with FormData. Blogpost Uploading files using ‘fetch’ and ‘FormData’ by MuffinMan explains this best.

I’m also left with a question: how do I set the title and description when uploading assets? Currently the title is automatically set to the file name, but that’s not an ideal situation.

Using a meta field, e.g.:

in Above example I’m uploading two assets and defining the title and description for each one

Thanx once again Paulo!