good_nabuco Posted November 4, 2016 Share Posted November 4, 2016 (edited) Hello everybody I would like to update the manufacturers via API. I tried to use this code: require_once('./PSWebServiceLibrary.php'); ... foreach ($resources as $nodeKey => $node) { $resources->$nodeKey = $_POST[$nodeKey]; } //web service call try { $opt = array('resource' => 'manufacturers'); $opt['putXml'] = $xml->asXML(); $opt['id'] = $id_c; $xml = $webService->edit($opt); } catch (PrestaShopWebserviceException $ex) { // Errors $trace = $ex->getTrace(); if ($trace[0]['args'][0] == 404) echo 'Bad ID'; else if ($trace[0]['args'][0] == 401) echo 'Bad auth key'; else echo 'Other error<br />'.$ex->getMessage(); } ... This error is generated from the web service library, precisely from the 'edit' function: ... public function edit($options) { $xml = ''; if (isset($options['url'])) $url = $options['url']; elseif ((isset($options['resource'], $options['id']) || isset($options['url'])) && $options['putXml']) { $url = (isset($options['url']) ? $options['url'] : $this->url.'/api/'.$options['resource'].'/'.$options['id']); $xml = $options['putXml']; if (isset($options['id_shop'])) echo $url .= '&id_shop='.$options['id_shop']; if (isset($options['id_group_shop'])) $url .= '&id_group_shop='.$options['id_group_shop']; } else throw new PrestaShopWebserviceException('Bad parameters given'); $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_POSTFIELDS => $xml)); self::checkStatusCode($request['status_code']);// check the response validity return self::parseXML($request['response']); } ... Anybody can tell me how I can solve this problem? Thank you! Edited November 4, 2016 by good_nabuco (see edit history) Link to comment Share on other sites More sharing options...
good_nabuco Posted November 8, 2016 Author Share Posted November 8, 2016 Nobody can help me to solve this problem? Thanks! Link to comment Share on other sites More sharing options...
good_nabuco Posted November 11, 2016 Author Share Posted November 11, 2016 Ok, I've solved! I have removed (with unset()) the 'link_rewrite' node from the xml, beacouse it has the clause 'notFiltrable="true"'. Anyway, I have added this line: unset($resources->link_rewrite); before the web service call. Bye! 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