006bonetti Posted May 3, 2012 Share Posted May 3, 2012 Hello, I need to use REST webservices to handle my eshop. I followed the tutorial "Using the REST webservice" and found a problem. My URL translation is not working properly. I've generated new .htaccess file, having inside <IfModule mod_rewrite.c> # URL rewriting module activation RewriteEngine on # URL rewriting rules RewriteRule ^api/?(.*)$ /prestashop/webservice/dispatcher.php?url=$1 [QSA,L] </IfModule> Rewriting in prestashop is enabled via Back Office accordingly, I generated the key and set all needed permissions. Rewriting in Apache is enabled too, module is loaded. Apache is version 2.2, hosted on localhost. If I access http://localhost/pre.../dispatcher.php it works, i get a tree of xlinks. But according translated URL http://localhost/prestashop/api results in error 404. Same error is returned while trying to access http://localhost/pre...p/api/customers etc.. Problem is, that I want to use created PHP scripts (0-CustomersList.php, 1-Retrieve.php) and in all those script, URL translation is used. Snippet of 0-CustomersList.php: // Here we define constants /!\ You need to replace this parameters define('DEBUG', true); // Debug mode define('PS_SHOP_PATH', 'http://localhost/'); // Root path of your PrestaShop store define('PS_WS_AUTH_KEY', 'ZQ88PRJX5VWQHCWE4EE7SQ7HPNX00RAJ'); // Auth key (Get it in your Back Office) require_once('./PSWebServiceLibrary.php'); Any ideas? Link to comment Share on other sites More sharing options...
006bonetti Posted May 3, 2012 Author Share Posted May 3, 2012 Just as an example of nonworking address resolution, I uploaded correct CustomersList.php to the server and executed it, here is a reply. URL is http://localhost/prestashop/webservice/CustomersList.php HTTP REQUEST HEADER GET //api/customers HTTP/1.1 Authorization: Basic V0FESDZTQkFZNkZUOTdDWU9BRElVVFlNWlJSSFlPMlk6 Host: localhost Accept: */* HTTP RESPONSE HEADER HTTP/1.1 404 Not Found Date: Thu, 03 May 2012 11:47:18 GMT Server: Apache/2.2.22 (Fedora) Content-Length: 286 Connection: close Content-Type: text/html; charset=iso-8859-1 RETURN HTTP BODY <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The requested URL /api/customers was not found on this server.</p> <hr> <address>Apache/2.2.22 (Fedora) Server at localhost Port 80</address> </body></html> Bad ID Customer's List Link to comment Share on other sites More sharing options...
symphonyx Posted May 16, 2012 Share Posted May 16, 2012 Hello, have you try to access `http://localhost/prestashop/api/customers' directly on you browser ? Link to comment Share on other sites More sharing options...
massimopasquali Posted November 13, 2015 Share Posted November 13, 2015 I have tried, but I can't : error 401. Prestashop v.1.6.1 Any suggests!? Link to comment Share on other sites More sharing options...
massimopasquali Posted August 23, 2016 Share Posted August 23, 2016 Hello,I have made a new bit step, now I have the .htaccesss and if I test on my ubuntu 16 server it told me that the rewrite module is active, but keeps giving me error. this is my .htaccess, have you any suggest to give me? thanks in advanceOrder deny,allowDeny from allRewriteEngine on# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution# http://www.prestashop.com - http://www.prestashop.com/forums<IfModule mod_rewrite.c><IfModule mod_env.c>SetEnv HTTP_MOD_REWRITE On</IfModule>RewriteEngine on#Domain: www.cimminob2b.comRewriteRule . - [E=REWRITEBASE:/]RewriteRule ^api$ api/ [L]RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]# AlphaImageLoader for IE and fancyboxRewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]</IfModule>AddType application/vnd.ms-fontobject .eotAddType font/ttf .ttfAddType font/otf .otfAddType application/x-font-woff .woff<IfModule mod_headers.c> <FilesMatch "\.(ttf|ttc|otf|eot|woff|svg)$"> Header add Access-Control-Allow-Origin "*" </FilesMatch></IfModule>#If rewrite mod isn't enabledErrorDocument 404 /index.php?controller=404# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again Link to comment Share on other sites More sharing options...
massimopasquali Posted August 23, 2016 Share Posted August 23, 2016 if I try to access directly at http://www.cimminob2b.com/webservice/dispatcher.php?url=customers this is the result <prestashop><customers><customer id="1" xlink:href="http://www.cimminob2b.com/api/customers/1"/></customers></prestashop> but If I try to access by http://www.cimminob2b.com/api the result is ( I have tested that ini php.ini there was mod_rewrite and also I checked that on my ubuntu 16 that the rewrite module is active ) : Any suggest? Not FoundThe requested URL /api was not found on this server. Apache/2.4.18 (Ubuntu) Server at www.cimminob2b.com Port 80 Link to comment Share on other sites More sharing options...
kirubanidhi Posted December 1, 2016 Share Posted December 1, 2016 Hello, The Prestashop web service is working http does not work https http://ZZ6K8XTP8FYT2...w.pts.local/api above this url is working for me but I changed this url from http to https is not working for me. Prestashop front and back office page is running through https. Link to comment Share on other sites More sharing options...
Recommended Posts