简体   繁体   English

使用Java和Magento Rest API。 404错误

[英]Using Java & Magento Rest API. 404 Error

I'm trying to use the Java to Magento Rest API using scribe. 我正在尝试使用scribe使用Java to Magento Rest API。 I have followed the tutorial outlined here. 我遵循了这里概述的教程。 I am new to Magento and REST in general. 我是Magento和REST的新手。 I am using Java 1.5 on a Tomcat 6.0 server. 我在Tomcat 6.0服务器上使用Java 1.5。 Magento is 1.8.0.0. Magento是1.8.0.0。

http://gmartinezgil.wordpress.com/2013/08/05/using-the-magento-rest-api-in-java-with-scribe/ http://gmartinezgil.wordpress.com/2013/08/05/using-the-magento-rest-api-in-java-with-scribe/

So I have currently got oAuth token and Validation working. 因此,我目前拥有oAuth令牌和验证功能。

    final String MAGENTO_API_KEY = "My Key";
    final String MAGENTO_API_SECRET = "My Secret";
    final String MAGENTO_REST_API_URL = "http://127.0.0.1/magento/api/rest";

I can Authorize the application and get the verifier code fine, but when trying to retrieve the XML(I think?) from the REST URL I get the following. 我可以对应用程序进行授权并获得正确的验证程序代码,但是当尝试从REST URL检索XML(我认为吗?)时,我得到了以下内容。

    404 
    <!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 /magento/api/rest/products was not found on this server.</p> 
    </body></html>

I have tried getting data from /magento/index.php/api/rest and the same issue arises. 我尝试从/magento/index.php/api/rest获取数据,并且出现相同的问题。

So this leads me to believe I have left out something for the REST API. 因此,这使我相信我为REST API遗漏了一些东西。 Through some research I had seen some changes may have to be made to the htaccess file, but I'm not sure if that is right and what it should be. 通过一些研究,我看到可能需要对htaccess文件进行一些更改,但是我不确定这是否正确以及应该正确。

These are the entries in the htaccess file within Magento at the moment. 这些是目前Magento中htaccess文件中的条目。

    ############################################
    ## uncomment next line to enable light API calls processing

    #    RewriteRule ^api/([a-z][0-9a-z_]+)/?$ api.php?type=$1 [QSA,L]

    ############################################
    ## rewrite API2 calls to api.php (by now it is REST only)

        RewriteRule ^/api/rest api.php?type=rest [QSA,L]

Any help regarding this would be brilliant. 关于此的任何帮助将是很棒的。 I'm not sure if it is the htaccess file or something else, but I have been trying different things for about a week now to no avail. 我不确定这是htaccess文件还是其他文件,但是大约一个星期以来,我一直在尝试不同的方法,但无济于事。

Can you access any pages other than the homepage in your Magento site at the /magento/ URL? 您可以通过/magento/ URL访问Magento站点中主页以外的任何页面吗? Based on the generic (non Magento) 404 page 基于通用(非Magento)404页面

404 
<!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 /magento/api/rest/products was not found on this server.</p> 
</body></html>

it sounds like your web-server isn't catching the URL rewrite rules that redirect requests to Magento's index.php "front-controller/bootstrap" file. 听起来您的网络服务器未捕获将请求重定向到Magento的index.php “ front-controller / bootstrap”文件的URL重写规则。

The causes for this are myriad — but I'd check that your RewriteBase folder is set correctly. 造成这种情况的原因RewriteBase -但我要检查您的RewriteBase文件夹设置是否正确。

############################################
## you can put here your magento root folder
## path relative to web root

    RewriteBase /magento/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM