Jump to content

prestapyt to add product ERROR


Recommended Posts

I'm trying to create a script to add products to prestashop, through Python.

 

I'm using prestapyt library; I can read files, I can get template for new file but I cannot upload a new file. This is what I have:

from prestapyt import PrestaShopWebServiceError
from prestapyt import PrestaShopWebService
from prestapyt import PrestaShopWebServiceDict

DEBUG = 'true'
PS_SHOP_PATH = MYPATH
PS_WS_AUTH_KEY = MYKEY

prestashop = PrestaShopWebServiceDict(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG)
myproducts = prestashop.search('products');
addNewProduct(prestashop)

where

def addNewProduct(prestashop):

blank_product = prestashop.get('products', options={'schema': 'blank'});

pprint(blank_product)

blank_product.update({
'active': '1',
'additional_shipping_cost': '',
'advanced_stock_management': '',
'description': {'language': {'attrs': {'id': '2'}, 'value': 'DESCRIPTION!!!'[spam-filter],
'description_short': {'language': {'attrs': {'id': '2'},
'value': 'SHORT DESCRIPTION!!!'[spam-filter],
'id': '23',
'id_category_default': '2',
'name': {'language': {'attrs': {'id': '2'}, 'value': 'NAME'[spam-filter],
'new': '1',
'price': '23',
'reference': 'MYREF',
'show_price': '1',
'width': ''

}) prestashop.add('products', blank_product)

 

 

When run this scrip I get the following:

 

Execute url: MYPATH/api/products / method: POST Response code: 400

Response headers:

{'status': '400', 'psws-version': '1.6.1.6', 'x-powered-by': 'PrestaShop Webservice', 'transfer-encoding': 'chunked', 'set-cookie': 'PrestaShop-a0d2999cb4d9d838ea9bbca3cf8a7a22=gv2rmNYce013aHwM2TQ7718d8sl%2BCmTtT1hO7pqS6ItiGKUPTa%2FGUwpTprJh9pihDKJbQNq4DKb0N6SYqC5nxBM4Q%2F1AFCrubceV8yPEcMo%3D000079; expires=Tue, 27-Sep-2016 21:15:16 GMT; Max-Age=1728000; path=MYPATH; domain=SOMETHING; httponly', 'access-time': '1473282916', 'connection': 'close', 'execution-time': '0.008', 'date': 'Wed, 07 Sep 2016 21:15:16 GMT', 'server': 'Apache', 'content-type': 'text/xml;charset=utf-8'}

Response body:

'PrestaShop error: 400 Bad Request. Internal error. To see this error please display the PHP errors.'

 

 

 

Any ideia?

 

 

Thanks!

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