I'm running the following request to search products by SKU using the Magento 2 REST API:

curl -X GET "http://localhost/rest/V1/products?searchCriteria[filterGroups][0][filters][0][field]=sku&searchCriteria[filterGroups][0][filters][0][value]=%24-MB01%&searchCriteria[filterGroups][0][filters][0][conditionType]=like"

Summary: look for products with sku that contain the string "24-MB01"

Disregarding auth and content params, the issue is that the value %24-MB01% is misinterpreted as $-MB01% by the API as you can see:

   "total_count" : 0,
   "search_criteria" : {
      "filter_groups" : [
            "filters" : [
                  "condition_type" : "like",
                  "value" : "$-MB01%",
                  "field" : "sku"
   "items" : []

How can I escape it?


1 Answer 1


You don't need to wrap the sku with %, you can directly put the sku and the condition like will do the search query for products with sku 24-MB01

You can try %2524-MB01%25

curl -X GET "http://localhost/rest/V1/products?searchCriteria[filterGroups][0][filters][0][field]=sku&searchCriteria[filterGroups][0][filters][0][value]=%2524-MB01%25&searchCriteria[filterGroups][0][filters][0][conditionType]=like"
  • Without the % it's generating the wrong condition WHERE ((e.sku LIKE '24-MB01')) the result I'm expecting is WHERE ((e.sku LIKE '%24-MB01%')) May 7, 2019 at 1:09
  • you can try updated answer
    – fmsthird
    May 7, 2019 at 1:19
  • Now it's back to looking for WHERE ((e.sku LIKE '$-MB01%')) screencast.com/t/HUr1XOTdrrd3 May 7, 2019 at 12:55
  • hmm that is strange. I tested it in my machine using postman and it works. can you check in your postman first then check the curl code from there.
    – fmsthird
    May 7, 2019 at 13:34
  • 1
    That's the exactly command: curl -X GET "http://localhost/rest/V1/products?searchCriteria[filterGroups][0][filters][0][field]=sku&searchCriteria[filterGroups][0][filters][0][value]=%24-MB01%&searchCriteria[filterGroups][0][filters][0][conditionType]=like" -H "Content-type: application/json" -H "Authorization: Bearer 01tcewo3flyforzum0ysi7kvoxz4y58q" -g May 7, 2019 at 20:07

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.