Jump to content

API gives raw SQL error and HTTP code 400 when uploading image


Jorr.it

Recommended Posts

When I would try to upload (add) new images to an existing product having existing images using the API, it will return an error:

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<errors>
<error>
<code><![CDATA[97]]></code>
<message><![CDATA[[SQL Error] Duplicate entry '16-1' for key 'id_product_cover'. From DbCore->insert() Query was : INSERT INTO `ps_image` (`id_product`, `position`, `cover`) VALUES ('16', '6', '1')]]></message>
</error>
<error>
<code><![CDATA[97]]></code>
<message><![CDATA[[SQL Error] Duplicate entry '16-1' for key 'id_product_cover'. From ObjectModelCore->add() Query was : INSERT INTO `ps_image` (`id_product`, `position`, `cover`) VALUES ('16', '6', '1')]]></message>
</error>
<error>
<code><![CDATA[76]]></code>
<message><![CDATA[Error while creating image]]></message>
</error>
</errors>
</prestashop>

It sounds fair that a product can only use one image at a time as a cover. The problem is that I don't see any possibility in the API to manage which image will become the product cover. 

To upload product images, I use exactly the PHP code as suggested in the PrestaShop webservice tutorial:

https://devdocs.prestashop.com/1.7/webservice/tutorials/advanced-use/image-management/#using-curl

Using PrestaShop 1.7.6.4.

Could this be a bug? Or am I doing anything wrong?

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...