0

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:

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

0

I tried this in Postman with the SKU -

5%^&*[]}{+=""_@.#~?/\/||?|?><|>:ДЄ

and encoded it to -

5%25%5E%26%2A%5B%5D%7D%7B%2B%3D%22%22_%40.%23~%3F%2F%5C%2F%7C%7C%3F%7C%3F%3E%3C%7C%3E%3A%D0%94%D0%84

and used this URL to do a GET -

/rest/all/V1/stockItems/5%25%5E%26%2A%5B%5D%7D%7B%2B%3D%22%22_%40.%23~%3F%2F%5C%2F%7C%7C%3F%7C%3F%3E%3C%7C%3E%3A%D0%94%D0%84

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.

| improve this answer | |
  • 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 '19 at 9:34
  • In the GET url you have "/rest/V1/stockItems/rest/SKU" - try using "/rest/all/V1/stockItems/SKU" – BigDaddyL Nov 20 '19 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 '19 at 10:02
  • could you please share your Magento version? I can't reach any product having / in the SKU – vbyno Nov 20 '19 at 12:53
  • This was done on M2 Commerce 2.3.2 – BigDaddyL Nov 20 '19 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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