Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST API unable to make requests with slash (/) in SKU #8615

Closed
mplccp opened this issue Feb 20, 2017 · 11 comments
Closed

REST API unable to make requests with slash (/) in SKU #8615

mplccp opened this issue Feb 20, 2017 · 11 comments
Assignees
Labels
bug report Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@mplccp
Copy link

mplccp commented Feb 20, 2017

Inside the REST API, it is impossible to access a resource that requires an SKU if the SKU contains a forward slash.

Preconditions

  1. Tested in CE 2.1.2 and CE 2.1.3. No indication of fix in 2.1.4 release notes

Steps to reproduce

  1. Fresh install
  2. Create product (of any type) with SKU containing /, e.g. "CLE-056621/6"
  3. Make REST request with encoded SKU (as Swagger does) e.g. "V1/products/CLE-056621%2F6", "/V1/products/CLE-056621%2F6/media"

Expected result

  1. Should be possible to make a request with encoded SKU, or by product ID

Actual result

  1. A request with a slash ("CLE-056621/6") returns "Not found" 404
  2. A request with encoded SKU ("CLE-056621%2F6") returns
    { "message": "Requested product doesn't exist" }
@misha-kotov misha-kotov added 2.0.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog labels Feb 22, 2017
@misha-kotov
Copy link

Thanks for reporting - internal issue number is MAGETWO-60899.

@AirmanAJK
Copy link

It appears that this is an issue with Apache rather than Magento. You might have noticed that the 404 response codes are Apache generated instead of the usual Magento 404 pages. This is because, by default, forward slashes cannot be encoded in URLs without getting rejected. Add the option "AllowEncodedSlashes On" in either your global or virtual host config (or maybe in the Magento .htaccess, though this could be a security risk for users who would never make requests with encoded forward slashes).

This worked for me. Good luck.

@magento-engcom-team magento-engcom-team added 2.0.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed G1 Passed labels Sep 5, 2017
@magento-engcom-team
Copy link
Contributor

@mplccp, thank you for your report.
We've created internal ticket(s) MAGETWO-60899 to track progress on the issue.

@magento-engcom-team magento-engcom-team added 2.2.x Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Oct 11, 2017
@Tjitse-E
Copy link
Contributor

@AirmanAJK can you share your .htaccess or apache config? I'm trying to set AllowEncodedSlashes On, but this results in a 500 server error.

@agata-maksymiuk
Copy link

For those who can't wait to fix it I suggest temporary solution here:
https://magento.stackexchange.com/questions/142056/how-to-get-magento2-product-with-rest-if-sku-has-slash/201892#201892

@RomaKis RomaKis self-assigned this Dec 1, 2017
@keijsers
Copy link

It seems to be resolved somehow or version 2.1.9 is not affected. I've been able to successfully create and update a product with slashes in the sku. Encode the slash using '%2f'

For the update I used the following example API call:

PUT: /rest/all/V1/products/article%2fwith%2fslash%2fin%2fsku
JSON: {
"product": {
"status": 1,
"type_id": "simple",
"name": "Test article is updated..."
}
}

@RomaKis
Copy link
Contributor

RomaKis commented Dec 15, 2017

Working on this.

@okorshenko
Copy link
Contributor

Hi @mplccp
The issue has been fixed and delivered in 2.2-develop branch. Will be available with upcoming patch release.

@stephenbori
Copy link

Has their been progress on this as still getting this issue in 2.2.3

@JaredAllen1
Copy link

We are still experiencing this issue in 2.3.3.

@ihor-sviziev
Copy link
Contributor

@stephenbori @JaredAllen1
Are you using Apache? If yes - did you tried to to set following option in virtualhost?

AllowEncodedSlashes NoDecode

Ref: #13343 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests