Jump to content

Problém s překladem URL u REST API


Recommended Posts

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 URLhttp://localhost/prestashop/api results in error 404. Same error is returned while trying to accesshttp://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');

 

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/pre...stomersList.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

 

Máte někdo nějaké nápady, jak toto řešit?

Link to comment
Share on other sites

×
×
  • Create New...