wagnerlucian Posted July 12, 2013 Share Posted July 12, 2013 Hi, please, I have a strange problem. I am trying to create php file with the POST a NEW product to the prestashop over the webservice. I'm using the PSWebServiceLibrary.php as in the docs prestashop (Using the REST webservice). I send the url_rewrite but return this error "Property Product->link_rewrite is empty" HTTP REQUEST HEADER GET //api/products?schema=blank HTTP/1.1 Authorization: Basic T0Q1U01RWktGSUIwVFhKMEhLOElNVkFHNjAyU0s5TFM6 Host: nbs Accept: */* HTTP RESPONSE HEADER HTTP/1.1 200 OK Date: Fri, 12 Jul 2013 17:37:37 GMT Server: Apache/2.2.22 (Ubuntu) Vary: Authorization,Host,Accept-Encoding X-Powered-By: PrestaShop Webservice Access-Time: 1373650667 PSWS-Version: 1.5.4.1 Execution-Time: 9.322 Content-Sha1: ccac02639a1bf1cc15921c056d69423d7c824415 Set-Cookie: ffdbd13d96d903c026c4876e97eb63a4=35HYDIi%2BnovSp5eJ9wXcV%2BV0Lay97L5KBseurnA10drmdPBvTUgORuRznr%2FG6blpOnF50IgS8DUB9gTIfYn0GQ%3D%3D000060; expires=Thu, 01-Aug-2013 17:37:37 GMT; path=/; httponly Content-Length: 2917 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></id> <id_manufacturer></id_manufacturer> <id_supplier></id_supplier> <id_category_default></id_category_default> <new></new> <cache_default_attribute></cache_default_attribute> <id_default_image></id_default_image> <id_default_combination></id_default_combination> <id_tax_rules_group></id_tax_rules_group> <id_shop_default></id_shop_default> <reference></reference> <supplier_reference></supplier_reference> <location></location> <width></width> <height></height> <depth></depth> <weight></weight> <quantity_discount></quantity_discount> <ean13></ean13> <upc></upc> <cache_is_pack></cache_is_pack> <cache_has_attachments></cache_has_attachments> <is_virtual></is_virtual> <on_sale></on_sale> <online_only></online_only> <ecotax></ecotax> <minimal_quantity></minimal_quantity> <price></price> <wholesale_price></wholesale_price> <unity></unity> <unit_price_ratio></unit_price_ratio> <additional_shipping_cost></additional_shipping_cost> <customizable></customizable> <text_fields></text_fields> <uploadable_files></uploadable_files> <active></active> <redirect_type></redirect_type> <id_product_redirected></id_product_redirected> <available_for_order></available_for_order> <available_date></available_date> <condition></condition> <show_price></show_price> <indexed></indexed> <visibility></visibility> <advanced_stock_management></advanced_stock_management> <date_add></date_add> <date_upd></date_upd> <meta_description><language id="1"></language></meta_description> <meta_keywords><language id="1"></language></meta_keywords> <meta_title><language id="1"></language></meta_title> <link_rewrite><language id="1"></language></link_rewrite> <name><language id="1"></language></name> <description><language id="1"></language></description> <description_short><language id="1"></language></description_short> <available_now><language id="1"></language></available_now> <available_later><language id="1"></language></available_later> <associations> <categories> <category> <id></id> </category> </categories> <images> <image> <id></id> </image> </images> <combinations> <combinations> <id></id> </combinations> </combinations> <product_option_values> <product_options_values> <id></id> </product_options_values> </product_option_values> <product_features> <product_feature> <id></id> <id_feature_value></id_feature_value> </product_feature> </product_features> <tags> <tag> <id></id> </tag> </tags> <stock_availables> <stock_available> <id></id> <id_product_attribute></id_product_attribute> </stock_available> </stock_availables> <accessories> <product> <id></id> </product> </accessories> <product_bundle> <products> <id></id> <quantity></quantity> </products> </product_bundle> </associations> </product> </prestashop> HTTP REQUEST HEADER POST //api/products HTTP/1.1 Authorization: Basic T0Q1U01RWktGSUIwVFhKMEhLOElNVkFHNjAyU0s5TFM6 Host: nbs Accept: */* Content-Length: 2138 Content-Type: application/x-www-form-urlencoded HTTP RESPONSE HEADER HTTP/1.1 400 Bad Request Date: Fri, 12 Jul 2013 17:37:47 GMT Server: Apache/2.2.22 (Ubuntu) Vary: Authorization,Host,Accept-Encoding X-Powered-By: PrestaShop Webservice Access-Time: 1373650667 PSWS-Version: 1.5.4.1 Execution-Time: 0.041 Set-Cookie: ffdbd13d96d903c026c4876e97eb63a4=35HYDIi%2BnovSp5eJ9wXcV5P7XSVvNGXMex4w6IS9QaLmdPBvTUgORuRznr%2FG6blp7t0sgUkJR7v29qCbFKhVAQ%3D%3D000060; expires=Thu, 01-Aug-2013 17:37:47 GMT; path=/; httponly Content-Length: 264 Connection: close Content-Type: text/xml;charset=utf-8 XML SENT xml=<?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <product> <id></id> <id_manufacturer>0</id_manufacturer> <id_supplier>0</id_supplier> <id_category_default>1017</id_category_default> <new></new> <cache_default_attribute>0</cache_default_attribute> <id_default_image></id_default_image> <id_default_combination></id_default_combination> <id_tax_rules_group>1</id_tax_rules_group> <id_shop_default>1</id_shop_default> <reference>teste_qualquer</reference> <supplier_reference></supplier_reference> <location></location> <width>0.000000</width> <height>0.000000</height> <depth>0.000000</depth> <weight>1.000000</weight> <quantity_discount>0</quantity_discount> <ean13></ean13> <upc></upc> <cache_is_pack>0</cache_is_pack> <cache_has_attachments>0</cache_has_attachments> <is_virtual>0</is_virtual> <on_sale>0</on_sale> <online_only>0</online_only> <ecotax>0.000000</ecotax> <minimal_quantity>1</minimal_quantity> <price>99.99</price> <wholesale_price>99.99</wholesale_price> <unity></unity> <unit_price_ratio>0.000000</unit_price_ratio> <additional_shipping_cost>0.00</additional_shipping_cost> <customizable>0</customizable> <text_fields>0</text_fields> <uploadable_files>0</uploadable_files> <active>1</active> <redirect_type></redirect_type> <id_product_redirected>0</id_product_redirected> <available_for_order>1</available_for_order> <available_date>0000-00-00</available_date> <condition>new</condition> <show_price>1</show_price> <indexed>0</indexed> <visibility>both</visibility> <advanced_stock_management>0</advanced_stock_management> <date_add>2013-07-09 18:51:12</date_add> <date_upd>0000-00-00 00:00:00</date_upd> <meta_description>descript</meta_description> <meta_keywords>keywo</meta_keywords> <meta_title>title qualquer</meta_title> <link_rewrite>linkrewritedo</link_rewrite> <name>namoe drpos</name> <description>description</description> <description_short>descripton-sho</description_short> <available_now></available_now> <available_later></available_later> <associations></associations> </product> </prestashop> RETURN HTTP BODY <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <errors> <error> <code><![CDATA[84]]></code> <message><![CDATA[Validation error: "Property Product->link_rewrite is empty"]]></message> </error> </errors> </prestashop> Other error This call to PrestaShop Web Services failed and returned an HTTP status of 400. That means: Bad Request. Link to comment Share on other sites More sharing options...
spatium Posted August 12, 2013 Share Posted August 12, 2013 $resources_product->link_rewrite->language[0][0] = 'some_value' ; - will help you... Link to comment Share on other sites More sharing options...
mayek Posted March 20, 2014 Share Posted March 20, 2014 (edited) $resources_product->link_rewrite->language[0][0] = 'some_value' ; - will help you... Your solution will stop script after script time limit... My solution is: $resources -> link_rewrite= ' ' ; // Clean this object $resources -> link_rewrite -> addChild('language' , 'THERE WAS NAME OF PRODUCT/CATEGORY'); $resources -> link_rewrite -> language->AddAttribute('id', '1'); Edited March 20, 2014 by mayek (see edit history) Link to comment Share on other sites More sharing options...
spatium Posted March 20, 2014 Share Posted March 20, 2014 Maybe. I worked with PrestaShop 1.4 and helped me to this decision 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