I have a product with a very weird SKU (which is valid in Magento 2.3.2): enter image description here

Although, REST API requires using SKU as a part of URL to get the stock item info. How is it possible to use that SKU as a part of URL? If I don't encode it, it is, obviously, invalid URL. If I encode it, I'm getting an error:

<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>

3 Answers 3


I tried this in Postman with the SKU -


and encoded it to -


and used this URL to do a GET -


and got back a correct request.

enter image description here

I couldn't make out from the image the last two characters in your SKU, so used two random cyrillic script characters. Best bet would be to make sure you are encoding it correctly, or provide the exact characters you're trying to use.

  • I've created a new product whith the SKU you provided and the exact same encoding, but I've got the same result, even though it works fine for "simple" SKUs. screencast.com/t/jQdYtAvd3yo Maybe, there is any Magento setting that must be turned on? I just can't imagine why it works for you but doesn't work for me.
    – vbyno
    Nov 20, 2019 at 9:34
  • In the GET url you have "/rest/V1/stockItems/rest/SKU" - try using "/rest/all/V1/stockItems/SKU"
    – BigDaddyL
    Nov 20, 2019 at 9:38
  • Hm... I see it is the slash symbol (/) which breaks the encoding. So, it works fine for 5%^&*[]}{+=""_@.#~? (and its encoding 5%25%5E%26%2A%5B%5D%7D%7B%2B%3D%22%22_%40.%23~%3F). Although, as long as I add / to the SKU, it is not reachable (for encoding 5%25%5E%26%2A%5B%5D%7D%7B%2B%3D%22%22_%40.%23~%3F%2F) / Also, it works the same for rest/all or just rest. Maybe, it is DB issue? I have MariaDB 10.2 under the hood.
    – vbyno
    Nov 20, 2019 at 10:02
  • could you please share your Magento version? I can't reach any product having / in the SKU
    – vbyno
    Nov 20, 2019 at 12:53
  • This was done on M2 Commerce 2.3.2
    – BigDaddyL
    Nov 20, 2019 at 13:02

Similar sort of solution is available https://magento.stackexchange.com/questions/142056/how-to-get-magento2-product-with-rest-if-sku-has-slash

Above solution will consider all special characters in SKUs. Specially for product APIs


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.