senecheikh Posted February 27, 2012 Share Posted February 27, 2012 Hi, i read the whole CRUD tutorial thing, fair to say it's incomplete ! the issue is that i can't add products using the webservice with POST, i get the error HTTP 400 bad request ... here is the code : require_once('PSWebserviceLibrary.php'); $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $xml_product = $webService->get(array('resource' => 'products?schema=synopsis')); $resources_product = $xml_product->children()->children(); // champs requis $resources_product->quantity = 0; $resources_product->price = 1; $resources_product->out_of_stock = 2; $resources_product->name->language[0][0] = 'test'; $resources_product->link_rewrite->language[0][0] = 'test'; // par exemple pour vider les associations aux categories unset($resources_product->associations->categories->category); // associer a une categorie (id = 1) $resources_product->associations->categories->addChild('category')->addChild('id', 1); $xml_product = $webService->add(array('resource' => 'products', 'postXml' => $xml_product->asXML())); thanks 1 Link to comment Share on other sites More sharing options...
symphonyx Posted May 16, 2012 Share Posted May 16, 2012 You have to display the prestashop errors to know what happened. Go to the conf file and set the display error var to true. Some of the errors or due to some fields in your XML that don't have to be in add or update items. Even if there are in a the blank or synopsis xml. Regards Link to comment Share on other sites More sharing options...
peorthyr Posted February 14, 2013 Share Posted February 14, 2013 http://forge.prestashop.com/browse/PSCFI-3393?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel here some info about it. Link to comment Share on other sites More sharing options...
Recommended Posts