Adelino Vascncelos Posted February 12, 2020 Share Posted February 12, 2020 Hi I have some problems in create a category with force id This is my code $xmlResponse1 = $webService->get(['url' => _URL_ . '/api/categories?schema=blank']); $resources1 = $xmlResponse1->category[0]; unset($resources1->id); unset($resources1->position); unset($resources1->date_add); unset($resources1->date_upd); unset($resources1->level_depth); unset($resources1->nb_products_recursive); $f = $force ? 'true' : 'false'; $resources1->id = trim($params['Id Categoria']); $resources1->force_id = $f; $resources1->is_root_category = false; $resources1->active = 1; $resources1->name->language[0] = trim($params['Nombre']); $resources1->name->language[1] = trim($params['Nombre']); $resources1->link_rewrite->language[0] = Tools::link_rewrite(trim($params['Nombre'])); $resources1->link_rewrite->language[1] = Tools::link_rewrite(trim($params['Nombre'])); $resources1->id_parent = trim($params['Id Padre']); try{ $addedResources1 = $webService->add(['resource' => 'categories', 'postXml' => $xmlResponse1->asXML()]); }catch(PrestaShopWebserviceException $e){ $trace = $e->getTrace(); $resources2 = $addedResources1->errors->error; error_log_txt("Code: ".$resources2->code."\nMensagem: ".$resources2->message, 'error'); if ($trace[0]['args'][0] == 404) error_log_txt('Bad ID', 'error'); else if ($trace[0]['args'][0] == 401) error_log_txt('Bad auth key', 'error'); else error_log_txt("Other error\n".$e->getMessage(), 'error'); return false; } And the error is this RETURN HTTP BODY <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <errors> <error> <code><![CDATA[91]]></code> <message><![CDATA[id is forbidden when adding a new resource]]></message> </error> </errors> </prestashop> Link to comment Share on other sites More sharing options...
EnriqueER11 Posted August 19, 2020 Share Posted August 19, 2020 On 2/12/2020 at 4:56 AM, Adelino Vascncelos said: Hi I have some problems in create a category with force id This is my code $xmlResponse1 = $webService->get(['url' => _URL_ . '/api/categories?schema=blank']); $resources1 = $xmlResponse1->category[0]; unset($resources1->id); unset($resources1->position); unset($resources1->date_add); unset($resources1->date_upd); unset($resources1->level_depth); unset($resources1->nb_products_recursive); $f = $force ? 'true' : 'false'; $resources1->id = trim($params['Id Categoria']); $resources1->force_id = $f; $resources1->is_root_category = false; $resources1->active = 1; $resources1->name->language[0] = trim($params['Nombre']); $resources1->name->language[1] = trim($params['Nombre']); $resources1->link_rewrite->language[0] = Tools::link_rewrite(trim($params['Nombre'])); $resources1->link_rewrite->language[1] = Tools::link_rewrite(trim($params['Nombre'])); $resources1->id_parent = trim($params['Id Padre']); try{ $addedResources1 = $webService->add(['resource' => 'categories', 'postXml' => $xmlResponse1->asXML()]); }catch(PrestaShopWebserviceException $e){ $trace = $e->getTrace(); $resources2 = $addedResources1->errors->error; error_log_txt("Code: ".$resources2->code."\nMensagem: ".$resources2->message, 'error'); if ($trace[0]['args'][0] == 404) error_log_txt('Bad ID', 'error'); else if ($trace[0]['args'][0] == 401) error_log_txt('Bad auth key', 'error'); else error_log_txt("Other error\n".$e->getMessage(), 'error'); return false; } And the error is this RETURN HTTP BODY <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <errors> <error> <code><![CDATA[91]]></code> <message><![CDATA[id is forbidden when adding a new resource]]></message> </error> </errors> </prestashop> I have the same problem, can you solved it? Link to comment Share on other sites More sharing options...
p.Góra Posted October 29, 2022 Share Posted October 29, 2022 I have a similar problem when adding a product. Has anyone solved it? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now