down999 Posted July 7, 2012 Share Posted July 7, 2012 (edited) Hi, please, I have a little 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). Everything is working fine, except if I trying to add a html tags in the product description field, like <p>Content of the desciption</p> or <p>Content of the desciption</p> or <![CDATA[ <p>Content of the desciption</p> ]]> It returns me the error code 500 all time. I'm trying everything with the php html entities, but nothing works. Could somebody help with this issue? My code (with the HTML tags <p></p>): require_once('config/config.inc.php'); require_once('config/PSWebServiceLibrary.php'); $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $opt = array('resource' => 'products'); $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); Thanks! Working result: HTTP RESPONSE HEADER HTTP/1.1 201 Created Date: Sat, 07 Jul 2012 16:37:38 GMT Server: Apache/2.2.16 (Debian) DAV/2 PHP/5.4.4-2~dotdeb.0 mod_ssl/2.2.16 OpenSSL/0.9.8o X-Powered-By: PrestaShop Webservice Access-Time: 1341679058 PSWS-Version: 1.4.8.2 Execution-Time: 0.031 Content-Sha1: f494cf951052b39b83fe176a470dd638565292c7 Content-Length: 2927 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_manufacturer format="isUnsignedId"/> <id_supplier format="isUnsignedId"/> <id_category_default format="isUnsignedId"/> <out_of_stock required="true" format="isUnsignedInt"/> <new/> <cache_default_attribute/> <id_default_image not_filterable="true"/> <id_default_combination not_filterable="true"/> <reference maxSize="32" format="isReference"/> <supplier_reference maxSize="32" format="isReference"/> <location maxSize="64" format="isReference"/> <ean13 maxSize="13" format="isEan13"/> <upc maxSize="12" format="isUpc"/> <unity maxSize="10" format="isString"/> <id_tax_rules_group format="isUnsignedId"/> <id_color_default format="isUnsignedInt"/> <minimal_quantity format="isUnsignedInt"/> <price required="true" format="isPrice">1000</price> <additional_shipping_cost format="isPrice"/> <wholesale_price format="isPrice"/> <on_sale format="isBool"/> <online_only format="isBool"/> <ecotax format="isPrice"/> <unit_price format="isPrice"/> <width format="isUnsignedFloat"/> <height format="isUnsignedFloat"/> <depth format="isUnsignedFloat"/> <weight format="isUnsignedFloat"/> <quantity_discount format="isBool"/> <customizable format="isUnsignedInt"/> <uploadable_files format="isUnsignedInt"/> <text_fields format="isUnsignedInt"/> <active format="isBool">1</active> <available_for_order format="isBool"/> <condition format="isGenericName"/> <show_price format="isBool"/> <indexed format="isBool"/> <cache_is_pack format="isBool"/> <cache_has_attachments format="isBool"/> <quantity required="true">50</quantity> <meta_description maxSize="255" format="isGenericName"><language id="6" xlink:href="http://192.168.2.101/api/languages/6" format="isUnsignedId"/></meta_description> <meta_keywords maxSize="255" format="isGenericName"><language id="6" xlink:href="http://192.168.2.101/api/languages/6" format="isUnsignedId"/></meta_keywords> <meta_title maxSize="128" format="isGenericName"><language id="6" xlink:href="http://192.168.2.101/api/languages/6" format="isUnsignedId"/></meta_title> <link_rewrite required="true" maxSize="128" format="isLinkRewrite">blabla</link_rewrite> <name required="true" maxSize="128" format="isCatalogName">blabla</name> <available_now maxSize="255" format="isGenericName"><language id="6" xlink:href="http://192.168.2.101/api/languages/6" format="isUnsignedId"/></available_now> <available_later maxSize="255" format="IsGenericName"><language id="6" xlink:href="http://192.168.2.101/api/languages/6" format="isUnsignedId"/></available_later> <description format="isString">blabla</description> <description_short format="isString">blabla</description_short> <associations></associations> </product> </prestashop> RETURN HTTP BODY <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <product> <id><![CDATA[144]]></id> <id_manufacturer></id_manufacturer> <id_supplier></id_supplier> <id_category_default></id_category_default> <out_of_stock></out_of_stock> <new></new> <cache_default_attribute></cache_default_attribute> <id_default_image not_filterable="true"></id_default_image> <id_default_combination not_filterable="true"></id_default_combination> <position_in_category not_filterable="true" readonly="true"></position_in_category> <manufacturer_name not_filterable="true" readonly="true"></manufacturer_name> <reference></reference> <supplier_reference></supplier_reference> <location></location> <ean13></ean13> <upc></upc> <unity></unity> <id_tax_rules_group></id_tax_rules_group> <id_color_default></id_color_default> <minimal_quantity></minimal_quantity> <price><![CDATA[1000]]></price> <additional_shipping_cost></additional_shipping_cost> <wholesale_price></wholesale_price> <on_sale></on_sale> <online_only></online_only> <ecotax></ecotax> <unit_price></unit_price> <width></width> <height></height> <depth></depth> <weight></weight> <quantity_discount></quantity_discount> <customizable></customizable> <uploadable_files></uploadable_files> <text_fields></text_fields> <active><![CDATA[1]]></active> <available_for_order></available_for_order> <condition></condition> <show_price></show_price> <indexed></indexed> <cache_is_pack></cache_is_pack> <cache_has_attachments></cache_has_attachments> <quantity><![CDATA[50]]></quantity> <meta_description><language id="6" xlink:href="http://192.168.2.101/api/languages/6"><![CDATA[]]></language></meta_description> <meta_keywords><language id="6" xlink:href="http://192.168.2.101/api/languages/6"><![CDATA[]]></language></meta_keywords> <meta_title><language id="6" xlink:href="http://192.168.2.101/api/languages/6"><![CDATA[]]></language></meta_title> <link_rewrite><language id="6"></language></link_rewrite> <name><language id="6"></language></name> <available_now><language id="6" xlink:href="http://192.168.2.101/api/languages/6"><![CDATA[]]></language></available_now> <available_later><language id="6" xlink:href="http://192.168.2.101/api/languages/6"><![CDATA[]]></language></available_later> <description><language id="6"></language></description> <description_short><language id="6" xlink:href="http://192.168.2.101/api/languages/6"></language></description_short> <date_add readonly="true"><![CDATA[2012-07-07 18:37:38]]></date_add> <date_upd readonly="true"><![CDATA[2012-07-07 18:37:38]]></date_upd> <associations> <categories node_type="category"/> <images node_type="image"/> <combinations node_type="combinations"/> <product_option_values node_type="product_options_values"/> <product_features node_type="product_feature"/> <tags node_type="tag"/> </associations> </product> </prestashop> Not working result (with the HTML tags <p></p>): HTTP RESPONSE HEADER HTTP/1.1 500 Internal Server Error Date: Sat, 07 Jul 2012 16:38:57 GMT Server: Apache/2.2.16 (Debian) DAV/2 PHP/5.4.4-2~dotdeb.0 mod_ssl/2.2.16 OpenSSL/0.9.8o X-Powered-By: PrestaShop Webservice Access-Time: 1341679137 PSWS-Version: 1.4.8.2 Execution-Time: 0.006 Content-Length: 1258 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_manufacturer format="isUnsignedId"/> <id_supplier format="isUnsignedId"/> <id_category_default format="isUnsignedId"/> <out_of_stock required="true" format="isUnsignedInt"/> <new/> <cache_default_attribute/> <id_default_image not_filterable="true"/> <id_default_combination not_filterable="true"/> <reference maxSize="32" format="isReference"/> <supplier_reference maxSize="32" format="isReference"/> <location maxSize="64" format="isReference"/> <ean13 maxSize="13" format="isEan13"/> <upc maxSize="12" format="isUpc"/> <unity maxSize="10" format="isString"/> <id_tax_rules_group format="isUnsignedId"/> <id_color_default format="isUnsignedInt"/> <minimal_quantity format="isUnsignedInt"/> <price required="true" format="isPrice">1000</price> <additional_shipping_cost format="isPrice"/> <wholesale_price format="isPrice"/> <on_sale format="isBool"/> <online_only format="isBool"/> <ecotax format="isPrice"/> <unit_price format="isPrice"/> <width format="isUnsignedFloat"/> <height format="isUnsignedFloat"/> <depth format="isUnsignedFloat"/> <weight format="isUnsignedFloat"/> <quantity_discount format="isBool"/> <customizable format="isUnsignedInt"/> <uploadable_files format="isUnsignedInt"/> <text_fields format="isUnsignedInt"/> <active format="isBool">1</active> <available_for_order format="isBool"/> <condition format="isGenericName"/> <show_price format="isBool"/> <indexed format="isBool"/> <cache_is_pack format="isBool"/> <cache_has_attachments format="isBool"/> <quantity required="true">50</quantity> <meta_description maxSize="255" format="isGenericName"><language id="6" xlink:href="http://192.168.2.101/api/languages/6" format="isUnsignedId"/></meta_description> <meta_keywords maxSize="255" format="isGenericName"><language id="6" xlink:href="http://192.168.2.101/api/languages/6" format="isUnsignedId"/></meta_keywords> <meta_title maxSize="128" format="isGenericName"><language id="6" xlink:href="http://192.168.2.101/api/languages/6" format="isUnsignedId"/></meta_title> <link_rewrite required="true" maxSize="128" format="isLinkRewrite">blabla</link_rewrite> <name required="true" maxSize="128" format="isCatalogName">blabla</name> <available_now maxSize="255" format="isGenericName"><language id="6" xlink:href="http://192.168.2.101/api/languages/6" format="isUnsignedId"/></available_now> <available_later maxSize="255" format="IsGenericName"><language id="6" xlink:href="http://192.168.2.101/api/languages/6" format="isUnsignedId"/></available_later> <description format="isString"><p>blabla</p></description> <description_short format="isString">blabla</description_short> <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> <message><![CDATA[internal error. To see this error please display the PHP errors.]]></message> </error> <error> <message><![CDATA[internal error. To see this error please display the PHP errors.]]></message> </error> <error> <message><![CDATA[internal error. To see this error please display the PHP errors.]]></message> </error> <error> <message><![CDATA[internal error. To see this error please display the PHP errors.]]></message> </error> <error> <message><![CDATA[internal error. To see this error please display the PHP errors.]]></message> </error> <error> <message><![CDATA[internal error. To see this error please display the PHP errors.]]></message> </error> <error> <message><![CDATA[internal error. To see this error please display the PHP errors.]]></message> </error> <error> <message><![CDATA[internal error. To see this error please display the PHP errors.]]></message> </error> <error> <message><![CDATA[internal error. To see this error please display the PHP errors.]]></message> </error> <error> <message><![CDATA[internal error. To see this error please display the PHP errors.]]></message> </error> </errors> </prestashop> Edited July 7, 2012 by down999 (see edit history) Link to comment Share on other sites More sharing options...
down999 Posted July 7, 2012 Author Share Posted July 7, 2012 OK... sorry for duplicate!!! And thanks to gandalf76fr on the topic: http://www.prestashop.com/forums/topic/153588-resoluwebservice-probleme-description-tags-html/page__p__744353?do=findComment&comment=744353 Link to comment Share on other sites More sharing options...
dandumit Posted July 11, 2013 Share Posted July 11, 2013 could you please be a bit more explicit about the way how problem it's solved ? I'm not that good on French ... Link to comment Share on other sites More sharing options...
ambitos Posted November 12, 2013 Share Posted November 12, 2013 Hello. I try to add a product via web service and I receive bellow error code: RETURN HTTP BODY <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <errors> <error> <message><![CDATA[internal error. To see this error please display the PHP errors.]]></message> </error> </errors> </prestashop> I am searching 2 days but nothing. Please can anyone help me? My Code is below. (Same with code in top) define('DEBUG', true); define('_PS_DEBUG_SQL_', true); define('PS_SHOP_PATH', 'http://localhost/dev/clients/Anthagora/Prestashop/trunk/src/'); define('PS_WS_AUTH_KEY', 'CBYB5G5UVRA7FCN7JK2WZ625DFWG8SK3'); require_once ('./PSWebServiceLibrary.php'); $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $opt = array('resource' => 'products'); $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->language[0][0] = 'blabla'; $resources->description->language[0][0] = '<p>blabla</p>'; $resources->description_short->language[0][0] = '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...
ambitos Posted November 12, 2013 Share Posted November 12, 2013 Hello. I try to add a product via web service and I receive bellow error code: RETURN HTTP BODY <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <errors> <error> <message><![CDATA[internal error. To see this error please display the PHP errors.]]></message> </error> </errors> </prestashop> I am searching 2 days but nothing. Please can anyone help me? My Code is below. define('DEBUG', true); define('_PS_DEBUG_SQL_', true); define('PS_SHOP_PATH', 'http://localhost/dev...shop/trunk/src/'); define('PS_WS_AUTH_KEY', 'CBYB5G5UVRA7FCN7JK2WZ625DFWG8SK3'); require_once ('./PSWebServiceLibrary.php'); $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $opt = array('resource' => 'products'); $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->language[0][0] = 'blabla'; $resources->description->language[0][0] = '<p>blabla</p>'; $resources->description_short->language[0][0] = '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...
frafra85 Posted January 30, 2014 Share Posted January 30, 2014 http://www.prestashop.com/forums/topic/229629-webservice-how-to-set-product-quantity/ Link to comment Share on other sites More sharing options...
rajesh_kumar Posted January 11, 2016 Share Posted January 11, 2016 How can i add a new customer using url and api key without php... Link to comment Share on other sites More sharing options...
rajesh_kumar Posted January 11, 2016 Share Posted January 11, 2016 I want to register a new user using api. I am not using php. How can i register with using url like www.example.com/api/customer/?schema=blank&ws_key=key and next.... 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