Jump to content

Webservice API: POST combinations returns "parameter "id_product" required" even though it is present


Zintex

Recommended Posts

POST /combinations/ returns
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<errors>
<error>
<code><![CDATA[41]]></code>
<message><![CDATA[parameter "id_product" required]]></message>
</error>
</errors>
</prestashop>

My request body is:
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<combination>
        <id/>
        <id_product>27833</id_product>
        <location/>
        <ean13/>
        <isbn/>
        <upc/>
        <quantity/>
        <reference/>
        <supplier_reference/>
        <wholesale_price/>
        <price>-194.308943</price>
        <ecotax/>
        <weight/>
        <unit_price_impact/>
        <minimal_quantity>1</minimal_quantity>
        <low_stock_threshold/>
        <low_stock_alert/>
        <default_on/>
        <available_date/>
<associations>
<product_option_values>
        <product_option_value>
        <id/>
        </product_option_value>
</product_option_values>
<images>
        <image>
        <id/>
        </image>
</images>
</associations>
</combination>
<associations><product_option_values><product_option_value><id>21</id></product_option_value></product_option_values></associations></prestashop>

A product with given id exists and provide id_product, so I don't understand why this error occurs.
Prestashop version is 1.7.5.2

Link to comment
Share on other sites

Nevermind, there are 2 <associacions> and one of them is beyond <combination>. 
There was an error in PHP code I used to generate that xml:
my incorrect code: $xml->associations->product_option_values->product_option_value[]->id = $item;

new correct code: $xml->combination->associations->product_option_values->product_option_value[]->id = $item;

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...