1

A lot of our SKUs have spaces and forward slashes in them (eg: "PRODUCT1-DARK BLUE" and "PRODUCT2-DARK/RED". I'm able to curl to the products with spaces via url encoding:

    # sample SKU: "PRODUCT1-DARK BLUE"
    # encoded: "PRODUCT1-DARK%20BLUE"
    > curl -X GET -H "Authorization: Bearer" "https://www.magentosite.com/index.php/rest/V1/products/PRODUCT1-Dark%20Blue"
    > returns data successfully

But unfortunately I can't seem to fetch any of our SKUs with the forward slash.  For example:

    # sample SKU: "PRODUCT2-DARK/RED"
    # encoded: "PRODUCT2-Dark%2FRed"
    > curl -X GET -H "Authorization: Bearer" "https://www.magentosite.com/index.php/rest/V1/products/PRODUCT2-Dark%2FRed"
    > returns "The requested URL was not found on this server." error

  I've tried encoding other variations ("PRODUCT2-DARK\/RED", "PRODUCT2-DARK//RED", and "PRODUCT2-DARK/RED") with no luck.  Any other ideas of something I can try?

Outside of changing our SKUs, is still there a way I can still try to GET/POST to our catalog product data containing forward slash characters in their SKU?  I know I can use products?&searchCriteria, however I need to POST and not just GET.

Thank you for any assistance!

1

2 Answers 2

1

There was a similar question some years ago, here is the answer , I think it will help you.

2
  • your google-fu skills are far superior to mine, thank you! Mar 31, 2021 at 0:10
  • I had similar issue a long time ago, and I remember that someone had answered it. Glad helping you. Mar 31, 2021 at 7:37
0

Magento now supports slashes in the API but if using Apache2 the conf file for the virtual host must contain the line AllowEncodedSlashes NoDecode

If using varnish with apache2 to offload SSL then the conf file for that virtual host must also contain the line AllowEncodedSlashes NoDecode AND the proxy pass line should have the nocanon argument, eg: ProxyPass / http://x.x.x.x:81/ nocanon

This is tested and working on Magento 2.4.5-p1 with apache 2.4.18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.