我正在使用prestashop API prestapyt
我在我的网站中手动添加了一个类别,但是当我尝试通过API进行编辑时,它失败了。 即使是最简单的事情,也行不通:
ps = PrestaShopWebServiceDict(config.DOMAIN, config.KEY)
xml = ps.get('categories', 35)
ps.edit('categories',35,xml)
xml(类型DICT)加载正常,但.edit()
失败。
以下是回复
Traceback (most recent call last):
File "C:\Users\noukeys\Documents\psapi\main.py", line 31, in <module>
ps.edit('categories',35,xml)
File "C:\Python27\lib\site-packages\prestapyt\prestapyt.py", line 333, in edit
return self.edit_with_url(full_url, content)
File "C:\Python27\lib\site-packages\prestapyt\prestapyt.py", line 452, in edit_with_url
return super(PrestaShopWebServiceDict, self).edit_with_url(url, xml_content)
File "C:\Python27\lib\site-packages\prestapyt\prestapyt.py", line 344, in edit_with_url
return self._parse(self._execute(url, 'PUT', body=unicode_encode.encode(content), add_headers=headers)[2])
File "C:\Python27\lib\site-packages\prestapyt\prestapyt.py", line 171, in _execute
self._check_status_code(status_code)
File "C:\Python27\lib\site-packages\prestapyt\prestapyt.py", line 125, in _check_status_code
% (status_code, message_by_code[status_code]), status_code)
prestapyt.prestapyt.PrestaShopWebServiceError: 'This call to PrestaShop Web Services failed and returned an HTTP status of 400. That means: Bad Request.'
答案 0 :(得分:0)
我也遇到了编辑问题,但是我收到了501错误。原来我的主机不允许PUT请求。
答案 1 :(得分:0)
您可以在api中打开调试。
prestashop.debug = True
然后在config.inc.php中为您的商店启用display_errors。这有助于我调试请求错误的原因。错误消息非常清楚。