Martin Gruhn
Martin Gruhn

Reputation: 31

Shopware 6 Update/replace/overwrite pictures though API

There is a great guide how to upload pictures to Shopware 6.4: Add images via Shopware 6 API

But how do I update an image? I can get the media-id for the image, no problem, but if I use the _action route I will get an error the file already exists.

Upvotes: 3

Views: 2031

Answers (1)

Alex
Alex

Reputation: 35118

The request documented here should work.

If you are unsure with the API you can always do the according action in the admin panel (which uses the Shopware API itself).

In this cases you need to right-click on the image and choose the replace option. Then you can observer your browser's network tab (Ctrl+Shift+I) to look closer at the request the Shopware 6 admin panel is executing.

In my case this request looked like that:

/api/_action/media/add88aa462b44e4e93e06ef65a1542a8/upload?extension=pdf&fileName=dummy
Request Method: POST

Upvotes: 2

Related Questions