Dottor M Posted February 9, 2016 Share Posted February 9, 2016 Hi, I'll tried to add a product through webservice but I have some errors I have add new key with all permessions (for testing purpouse) but I still have the errors. I've tried in localhost and remote server.... Error is: BAD REQUEST HTTP REQUEST HEADER GET /prestashop/api/products?schema=synopsis HTTP/1.1 Host: localhost Authorization: Basic Mk1ZR01FM0I3Ukc4VDNUU0VYVEJWRVFSVlZZU1NITjQ6 Accept: */* HTTP RESPONSE HEADER HTTP/1.1 200 OK Date: Tue, 09 Feb 2016 11:25:45 GMT Server: Apache X-Frame-Options: SAMEORIGIN X-Powered-By: PrestaShop Webservice Access-Time: 1455017146 PSWS-Version: 1.6.1.4 Execution-Time: 0.017 Content-Sha1: 2e4912f17f4c707cef8490e420cc0dd595356de6 Vary: Accept-Encoding Content-Length: 5861 Content-Type: text/xml;charset=utf-8 RETURN HTTP BODY <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <product> <id_manufacturer format="isUnsignedId"></id_manufacturer> <id_supplier format="isUnsignedId"></id_supplier> <id_category_default format="isUnsignedId"></id_category_default> <new></new> <cache_default_attribute></cache_default_attribute> <id_default_image notFilterable="true"></id_default_image> <id_default_combination notFilterable="true"></id_default_combination> <id_tax_rules_group format="isUnsignedId"></id_tax_rules_group> <position_in_category notFilterable="true"></position_in_category> <manufacturer_name notFilterable="true" read_only="true" readOnly="true"></manufacturer_name> <quantity notFilterable="true" read_only="true" readOnly="true"></quantity> <type notFilterable="true"></type> <id_shop_default format="isUnsignedId"></id_shop_default> <reference maxSize="32" format="isReference"></reference> <supplier_reference maxSize="32" format="isReference"></supplier_reference> <location maxSize="64" format="isReference"></location> <width format="isUnsignedFloat"></width> <height format="isUnsignedFloat"></height> <depth format="isUnsignedFloat"></depth> <weight format="isUnsignedFloat"></weight> <quantity_discount format="isBool"></quantity_discount> <ean13 maxSize="13" format="isEan13"></ean13> <upc maxSize="12" format="isUpc"></upc> <cache_is_pack format="isBool"></cache_is_pack> <cache_has_attachments format="isBool"></cache_has_attachments> <is_virtual format="isBool"></is_virtual> <on_sale format="isBool"></on_sale> <online_only format="isBool"></online_only> <ecotax format="isPrice"></ecotax> <minimal_quantity format="isUnsignedInt"></minimal_quantity> <price required="true" format="isPrice"></price> <wholesale_price format="isPrice"></wholesale_price> <unity format="isString"></unity> <unit_price_ratio></unit_price_ratio> <additional_shipping_cost format="isPrice"></additional_shipping_cost> <customizable format="isUnsignedInt"></customizable> <text_fields format="isUnsignedInt"></text_fields> <uploadable_files format="isUnsignedInt"></uploadable_files> <active format="isBool"></active> <redirect_type format="isString"></redirect_type> <id_product_redirected format="isUnsignedId"></id_product_redirected> <available_for_order format="isBool"></available_for_order> <available_date format="isDateFormat"></available_date> <condition format="isGenericName"></condition> <show_price format="isBool"></show_price> <indexed format="isBool"></indexed> <visibility format="isProductVisibility"></visibility> <advanced_stock_management format="isBool"></advanced_stock_management> <date_add format="isDate"></date_add> <date_upd format="isDate"></date_upd> <pack_stock_type format="isUnsignedInt"></pack_stock_type> <meta_description maxSize="255" format="isGenericName"><language id="1" xlink:href="http://localhost/prestashop/api/languages/1" format="isUnsignedId" ></language></meta_description> <meta_keywords maxSize="255" format="isGenericName"><language id="1" xlink:href="http://localhost/prestashop/api/languages/1" format="isUnsignedId" ></language></meta_keywords> <meta_title maxSize="128" format="isGenericName"><language id="1" xlink:href="http://localhost/prestashop/api/languages/1" format="isUnsignedId" ></language></meta_title> <link_rewrite required="true" maxSize="128" format="isLinkRewrite"><language id="1" xlink:href="http://localhost/prestashop/api/languages/1" format="isUnsignedId" ></language></link_rewrite> <name required="true" maxSize="128" format="isCatalogName"><language id="1" xlink:href="http://localhost/prestashop/api/languages/1" format="isUnsignedId" ></language></name> <description format="isCleanHtml"><language id="1" xlink:href="http://localhost/prestashop/api/languages/1" format="isUnsignedId" ></language></description> <description_short format="isCleanHtml"><language id="1" xlink:href="http://localhost/prestashop/api/languages/1" format="isUnsignedId" ></language></description_short> <available_now maxSize="255" format="isGenericName"><language id="1" xlink:href="http://localhost/prestashop/api/languages/1" format="isUnsignedId" ></language></available_now> <available_later maxSize="255" format="IsGenericName"><language id="1" xlink:href="http://localhost/prestashop/api/languages/1" format="isUnsignedId" ></language></available_later> <associations> <categories nodeType="category" api="categories"> <category> <id required="true"></id> </category> </categories> <images nodeType="image" api="images"> <image> <id></id> </image> </images> <combinations nodeType="combination" api="combinations"> <combination> <id required="true"></id> </combination> </combinations> <product_option_values nodeType="product_option_value" api="product_option_values"> <product_option_value> <id required="true"></id> </product_option_value> </product_option_values> <product_features nodeType="product_feature" api="product_features"> <product_feature> <id required="true"></id> <id_feature_value xlink:href="http://localhost/prestashop/api/product_feature_values/" required="true"></id_feature_value> </product_feature> </product_features> <tags nodeType="tag" api="tags"> <tag> <id required="true"></id> </tag> </tags> <stock_availables nodeType="stock_available" api="stock_availables"> <stock_available> <id required="true"></id> <id_product_attribute required="true"></id_product_attribute> </stock_available> </stock_availables> <accessories nodeType="product" api="products"> <product> <id xlink:href="http://localhost/prestashop/api/product/" required="true"></id> </product> </accessories> <product_bundle nodeType="product" api="products"> <product> <id required="true"></id> <quantity></quantity> </product> </product_bundle> </associations> </product> </prestashop> HTTP REQUEST HEADER POST /prestashop/api/products HTTP/1.1 Host: localhost Authorization: Basic Mk1ZR01FM0I3Ukc4VDNUU0VYVEJWRVFSVlZZU1NITjQ6 Accept: */* Content-Length: 3202 Content-Type: application/x-www-form-urlencoded HTTP RESPONSE HEADER HTTP/1.0 500 Internal Server Error Date: Tue, 09 Feb 2016 11:25:46 GMT Server: Apache X-Frame-Options: SAMEORIGIN X-Powered-By: PHP/7.0.0RC7 Content-Length: 0 Connection: close Content-Type: text/html; charset=utf-8 XML SENT <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <product> <id_manufacturer format="isUnsignedId"/> <id_supplier format="isUnsignedId"/> <id_category_default format="isUnsignedId"/> <new/> <cache_default_attribute/> <id_default_image notFilterable="true"/> <id_default_combination notFilterable="true"/> <id_tax_rules_group format="isUnsignedId"/> <quantity notFilterable="true" read_only="true" readOnly="true">50</quantity> <type notFilterable="true"/> <id_shop_default format="isUnsignedId"/> <reference maxSize="32" format="isReference"/> <supplier_reference maxSize="32" format="isReference"/> <location maxSize="64" format="isReference"/> <width format="isUnsignedFloat"/> <height format="isUnsignedFloat"/> <depth format="isUnsignedFloat"/> <weight format="isUnsignedFloat"/> <quantity_discount format="isBool"/> <ean13 maxSize="13" format="isEan13"/> <upc maxSize="12" format="isUpc"/> <cache_is_pack format="isBool"/> <cache_has_attachments format="isBool"/> <is_virtual format="isBool"/> <on_sale format="isBool"/> <online_only format="isBool"/> <ecotax format="isPrice"/> <minimal_quantity format="isUnsignedInt"/> <price required="true" format="isPrice">1000</price> <wholesale_price format="isPrice"/> <unity format="isString"/> <unit_price_ratio/> <additional_shipping_cost format="isPrice"/> <customizable format="isUnsignedInt"/> <text_fields format="isUnsignedInt"/> <uploadable_files format="isUnsignedInt"/> <active format="isBool">1</active> <redirect_type format="isString"/> <id_product_redirected format="isUnsignedId"/> <available_for_order format="isBool"/> <available_date format="isDateFormat"/> <condition format="isGenericName"/> <show_price format="isBool"/> <indexed format="isBool"/> <visibility format="isProductVisibility"/> <advanced_stock_management format="isBool"/> <date_add format="isDate"/> <date_upd format="isDate"/> <pack_stock_type format="isUnsignedInt"/> <meta_description maxSize="255" format="isGenericName"><language id="1" xlink:href="http://localhost/prestashop/api/languages/1" format="isUnsignedId"/></meta_description> <meta_keywords maxSize="255" format="isGenericName"><language id="1" xlink:href="http://localhost/prestashop/api/languages/1" format="isUnsignedId"/></meta_keywords> <meta_title maxSize="128" format="isGenericName"><language id="1" xlink:href="http://localhost/prestashop/api/languages/1" format="isUnsignedId"/></meta_title> <link_rewrite required="true" maxSize="128" format="isLinkRewrite">blabla</link_rewrite> <name required="true" maxSize="128" format="isCatalogName">blabla</name> <description format="isCleanHtml"><p>blabla</p></description> <description_short format="isCleanHtml">blabla</description_short> <available_now maxSize="255" format="isGenericName"><language id="1" xlink:href="http://localhost/prestashop/api/languages/1" format="isUnsignedId"/></available_now> <available_later maxSize="255" format="IsGenericName"><language id="1" xlink:href="http://localhost/prestashop/api/languages/1" format="isUnsignedId"/></available_later> <associations></associations> </product> </prestashop> RETURN HTTP BODY this is the code define('PS_SHOP_PATH', 'http://localhost/prestashop'); define('PS_WS_AUTH_KEY', '2MYGME3B7RG8T3TSEXTBVEQRVVYSSHN4'); require("PrestaShop/PSWebServiceLibrary.php"); $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/products?schema=synopsis')); // $resources = $xml->children()->children(); unset($resources->position_in_category); unset($resources->manufacturer_name); $resources->price = '1000'; $resources->active = '1'; $resources->quantity = '50'; $resources->link_rewrite = 'blabla'; $resources->name = 'blabla'; $resources->description = '<p>blabla</p>'; $resources->description_short = 'blabla'; $resources->associations = ''; $opt = array('resource' => 'products'); $opt['postXml'] = $xml->asXML(); $xml = $webService->add($opt); Link to comment Share on other sites More sharing options...
DominicTFr Posted August 23, 2017 Share Posted August 23, 2017 C'est un vieux sujet, mais la réponse peut toujours aider ce qui cherchent désespérément. Le problème vient du fait de mettre le champs quantity dans la requete alors qu'il est en readOnly. 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