Prestashop: Prestashop 1.7 Webservice can not create products

Created on 17 May 2019  路  7Comments  路  Source: PrestaShop/PrestaShop

Hi,

i am currently trying to create products via the webservice of prestashop.
(via HTTP Request, not php code)

Currently the API always responds with 400 - "price required".

Unfortunately there is no appropriate documentation which concretely states what i have to send to the api.

I am sending a http request with the following body:

<product> <price>1999</price> </product>
I stripped the other fields, for brevity;

I really appreciate some help, a link to a good documentation, or a example Postman request.

I already read https://devdocs.prestashop.com/1.7/development/webservice/tutorials/prestashop-webservice-lib/

Thank you in advance!

1.7.5.2 No change required Products WS

Most helpful comment

@nhh,

You need to add this in your xml
<low_stock_alert>0</low_stock_alert>

Thanks!

All 7 comments

Hi @nhh,

Here is an example of an xml sent to add a new product via WS

<prestashop>
<product>
  <id/>
  <state>1</state>
  <id_category_default>2</id_category_default>
  <active>1</active>
  <advanced_stock_management>1</advanced_stock_management>
  <associations>
    <categories>
      <category><id>2</id></category>
    </categories>
  </associations>
  <reference>boom</reference>
  <name>
  <language id="1">abc.com</language></name>
  <price>100</price>
  <id_shop_default>1</id_shop_default>
  <low_stock_alert>0</low_stock_alert>
  <link_rewrite>abc.com</link_rewrite>
  <show_price>1</show_price>
  <minimal_quantity>1</minimal_quantity>
  <available_for_order>1</available_for_order>
</product>
</prestashop>

Also, you can follow our documentation: http://doc.prestashop.com/display/PS16/Using+the+PrestaShop+Web+Service
You can found some examples in our GitHub repository: https://github.com/PrestaShop/PrestaShop-webservice-lib
Thanks!

<prestashop>
    <product>
        <id/>
        <id_supplier/>
        <type/>
        <id_manufacturer/>
        <advanced_stock_management/>
        <id_category_default/>
        <id_shop_default/>
        <id_tax_rules_group/>
        <on_sale/>
        <online_only/>
        <ean13/>
        <upc/>
        <type>1</type>
        <ecotax/>
        <minimal_quantity/>
        <price>1999</price>
        <wholesale_price>1999</wholesale_price>
        <reference/>
        <active/>
        <redirect_type/>
        <available_for_order/>
        <condition/>
        <show_price/>
        <name>
            <language id="1">Wtf</language>
        </name>
        <description>
            <language id="1">Wtf</language>
        </description>
        <link_rewrite>wtf</link_rewrite>
    </product>
</prestashop>

@nhh, Your issue is solved?
Thanks!

Hi @khouloudbelguith,

This is what i am sending now - The Api unfortunately says "Unable to save resource"

It would be very useful if the documentatin mentions what is required and what is not. Especially if the documentation would be php independent. :)

Any ideas?

Thank you

@nhh,

You need to add this in your xml
<low_stock_alert>0</low_stock_alert>

Thanks!

@khouloudbelguith,

You saved my day! I am incredibly thankfully _

For all which are searching for a php independent request, that works:

Request:

POST https://your-prestashop/api/products&ws_key=YOUR-API-KEY

Request Body:

<prestashop>
    <product>
        <id/>
        <id_supplier/>
        <type/>
        <id_manufacturer/>
        <advanced_stock_management/>
        <low_stock_alert>0</low_stock_alert>
        <id_category_default/>
        <id_shop_default/>
        <id_tax_rules_group/>
        <on_sale/>
        <online_only/>
        <ean13/>
        <upc/>
        <type>1</type>
        <ecotax/>
        <minimal_quantity/>
        <price>1999</price>
        <wholesale_price>1999</wholesale_price>
        <reference/>
        <active/>
        <redirect_type/>
        <available_for_order/>
        <condition/>
        <show_price/>
        <name>
            <language id="1">Example</language>
        </name>
        <description>
            <language id="1">Example</language>
        </description>
        <link_rewrite>Example</link_rewrite>
    </product>
</prestashop>

Have a nice day!!

@nhh, you are welcome.
Feel free to open a new one when needed.
Thanks!

Was this page helpful?
0 / 5 - 0 ratings