Jump to content

Webservice Problems


Recommended Posts

I am having a couple issues with getting webservice at 100%. I have never worked with webservice and am very novice at Prestashop, php, mysql, etc. but I recently had to get ShipRush working with our cart and had to get webservice up and running and came across a few issues. I figured I would post here before submitting a bug as I am unsure if it is an issue in Prestashop or simply a PEBCAC.

 

I followed the guide here and just used the included PSWebServiceLibrary.php file to get started: http://doc.prestasho...hop+Web+Service

 

I am running 1.5.0.13, and had issues with the webservice not finding my shop id. I downloaded the trunk files for the webservice updating the folders: /classes/webservice and /webservice and it solved that issue. I then had to edit WebserviceRequest.php line 1216 Shop::getAssoTable to Shop::getAssoTables to solve the issue of the undefined method. Next it couldn't find any of my tables and I noticed there was what seemed to be an extra underscore after the table names that seemed to be coming from here:

FROM '.bqSQL(_DB_PREFIX_.$this->resourceConfiguration['retrieveData']['table'].'_'.$assoc['type']).' ';

 

so I took out the underscore:

FROM '.bqSQL(_DB_PREFIX_.$this->resourceConfiguration['retrieveData']['table'].''.$assoc['type']).' ';

 

So now most parts of the api are pushing out data in the form of xml when looking at /api/customers/1 and ShipRush seems to be getting the data for now.

 

I still seem to have issues when looking at /api/order_invoices/1 or /api/addresses/1 and others with the same error message:

 

<error>
<code>
<![CDATA[ 97 ]]>
</code>
<message>
<![CDATA[
[sql Error] Unknown column 'id_shop' in 'where clause'. Query was : SELECT 1 FROM ps_address WHERE ( id_shop = 1 ) AND id_address = 1 LIMIT 1
]]>
</message>
</error>
<error>

 

Hopefully some of the above info will help someone out with some of the headaches I have been faced with. Let me know if you need any other info to get this issue resolved or if I am doing something very wrong and need to make some corrections.

 

Thanks!

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

I'm facing similar problem trying to get web services work.

 

Nothing you mentioned did a thing for me, but at least direct calls such as http://localhost/pre...api/customers/1?id_shop=1 ,as long as any other, are working now! Note the "id_shop" parameter.

 

I had to write file .htaccess manually since PrestaShop didn't write it, and I changed some apache rules ('AllowOverride None' to 'AllowOverride All' for /var/www directory) too. There's no particular security issue since I'm working locally.

 

Next step for me is to get it work from code:

$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
$webService->setShop(1);

fails!

 

Even the following fails:

$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
$opt['url'] = PS_SHOP_PATH . "/api/customers/1?id_shop=1";
$xml = $webService->get($opt) ;

Note that passing the 'url' option overrides any other options.

 

Next try will be the following:

$opts = array(
 'http'=>array(
'method'=>"GET" // or POST, or...
 )
);
$context = stream_context_create($opts);
$content = file_get_contents(PS_SHOP_PATH . "/api/customers/1?id_shop=1", false, $context);

and then parse $content as XML (but not now, now it's time for sleeping ;) ).

 

Hope it helps us to go further!

Link to comment
Share on other sites

  • 6 months later...
  • 3 years later...

I have similar issue getting <code><![CDATA[97]]></code> when calling API product POST request in prestashop 1.6.1.4
 

This is what I get back with an internal 500. However I can POST customers and other things just not products. Bug? 

 

<errors>
<error>
<code><![CDATA[97]]></code>
<message><![CDATA[
 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3. From ProductAdd->hookactionProductSave() Query was : 
SELECT *
FROM ps_product_lang
WHERE id_product=]]></message>
</error>
<error>
<code><![CDATA[97]]></code>
<message><![CDATA[[sql Error] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit 1' at line 3. From ProductAdd->hookactionProductSave() Query was : 
SELECT *
FROM ps_stock_available
WHERE id_product= limit 1]]></message>
</error>
<error>
<code><![CDATA[97]]></code>
<message><![CDATA[[sql Error] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit 1' at line 3. From ProductAdd->hookactionProductSave() Query was : 
SELECT *
FROM ps_product
WHERE id_product= limit 1]]></message>
</error>
<error>
<code><![CDATA[97]]></code>
<message><![CDATA[[sql Error] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit 1' at line 3. From ProductAdd->hookactionProductSave() Query was : 
SELECT *
FROM ps_product_carrier
WHERE id_product= limit 1]]></message>
</error>
<error>
<code><![CDATA[97]]></code>
<message><![CDATA[[sql Error] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3. From ProductAdd->hookactionProductSave() Query was : 
SELECT *
FROM ps_image
WHERE id_product=]]></message>
</error>
</errors>
</prestashop>
Link to comment
Share on other sites

×
×
  • Create New...