Setting a product image via API


#1

Hey there!
Currently I am evaluating Sylius and it looks great so far. I am really impressed about the clean and modern code base and I am happy to have found a shop software which offers an API.

I was able to add products and variants through the API but currently struggling uploading and adding a product image.

This is how the body (the options array) of my post within the guzzlehttp request to api/v1/products/ looks like:

array(2)
 string "json" (4) => array(6)
   string "channels" (8) => array(1)
     integer 0 => string "default" (7)
   string "code" (4) => string "123456" (13)
   string "enabled" (7) => true
   string "images" (6) => array(1)
     integer 0 => array(1)
       string "type" (4) => string "cover" (5)
   string "mainTaxon" (9) => string "book" (4)
   string "translations" (12) => array(1)
     string "de_DE" (5) => array(2)
       string "name" (4) => string "Book Title" (40)
       string "slug" (4) => string "123456" (13)
 string "multipart" (9) => array(1)
   integer 0 => array(2)
     string "name" (4) => string "images[0][file]" (15)
     string "contents" (8) => resource

There is no error returned and the image is not added.

I already read the documentation, the example in the ProductApiTest, had a look at other API client implementations but haven’t found the problem.

It would really be nice if someone could give me a hint.

Thanks in advance,
Daniel