magenx / Magento-nginx-config

Default Nginx config for Magento 2
https://www.magenx.com
GNU General Public License v3.0
506 stars 211 forks source link

It seems there is no configuration for "Rest Api" #8

Closed yssource closed 8 years ago

yssource commented 8 years ago
  1. There is no "Rest Api" configuration for magento. 404 will be returned, if "http://magento.dev/api/rest/products"
  2. "SOAP/XML-RPC" is Ok, "http://magento.dev/api/v2_soap/?wsdl=1"
magenx commented 8 years ago

what exactly you want to see there?

There is no "Rest Api" configuration for magento. 404 will be returned, if "http://magento.dev/api/rest/products"

yssource commented 8 years ago

If add the following codes in file https://github.com/magenx/Magento-nginx-config/blob/master/magento/www/magento.conf

    location /api {
        #proxy_pass http://varnish;
        rewrite ^/api/rest /api.php?type=rest last;
        rewrite ^/api/v2_soap /api.php?type=v2_soap last;
        rewrite ^/api/soap /api.php?type=soap last;
    }

It will get the result what I need. The magento_api xml file, which looks like this

<magento_api>
...
<data_item>
<entity_id>16</entity_id>
<type_id>simple</type_id>
<sku>dress7-White-S</sku>
<color>16</color>
<size>3</size>
<description>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur pharetra faucibus congue. Aenean luctus dolor et purus malesuada luctus. Quisque ullamcorper ante viverra lectus fermentum quis rutrum erat sollicitudin. Fusce tortor massa.</p>
 <p>Faucibus ut blandit cursus, varius vel mauris. Maecenas nec ullamcorper enim. Vestibulum neque leo, vehicula in consectetur sit amet, fringilla eu purus. Pellentesque egestas, felis in hendrerit porta, mauris sem pharetra ligula, sit amet ultrices enim mi ac turpis. Ut sed nisi a magna blandit imperdiet ut eu urna. Integer id enim justo. Cras nulla mauris, rhoncus at commodo ac, pretium feugiat dui. Cras ullamcorper nisl non odio congue accumsan. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam erat volutpat.</p>
</description>
<short_description>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur pharetra faucibus congue. Aenean luctus dolor.
</short_description>
<meta_keyword/>
<name>Dress Example Size-S</name>
<meta_title/>
<meta_description/>
<regular_price_with_tax>100</regular_price_with_tax>
<regular_price_without_tax>100</regular_price_without_tax>
<final_price_with_tax>100</final_price_with_tax>
<final_price_without_tax>100</final_price_without_tax>
<is_saleable>1</is_saleable>
<image_url>
http://magento.dev/media/catalog/product/cache/0/image/9df78eab33525d08d6e5fb8d27136e95/placeholder/default/placeholder.jpg
</image_url>
</data_item>
...
</magento_api>
magenx commented 8 years ago

for me soap works either way, no need any rewrites, and rest works too if i create user/role and connect with client.

yssource commented 8 years ago

It is very strange. for me REST does not work me. when "http://mydomain/api/rest/products" SOAP works for me, when "http://mydomain/api/v2_soap/?wsdl=1".

And In order to make both of soap and rest working for me, I have to add the following rules.

    location /api {
        rewrite ^/api/rest /api.php?type=rest last;
        rewrite ^/api/v2_soap /api.php?type=v2_soap last;
        rewrite ^/api/soap /api.php?type=soap last;
    }