Showing results for 
Search instead for 
Did you mean: 

[REST API] Indexes and Lists

[REST API] Indexes and Lists

I've been evaluating Magento2 and I'm trying to understand how lists/indexes work for Resources.  


For example, I'm trying to list all orders or all customers.  To do that, I do something like this:

curl -X GET "" \           
     -H "Authorization: Bearer abc123"

That yields:

{"message":"%fieldName is a required field.","parameters":{"fieldName":"criteria"},"trace":"#0 \/vagrant\/data\/magento2\/app\/code\/Magento\/Webapi\/Controller\/Rest.php(177): Magento\\Framework\\Webapi\\ServiceInputProcessor->process('Magento\\\\Sales\\\\A...', 'getList', Array)\n#1


My understanding of the above response is that I should be passing search parameters as part of this request, or perhaps using `/v1/search` instead.  


In either case, I'm not 100% clear on how to structure and pass in search parameters.  I checked out the API spec and saw that there are fields like: requestName, filterGroups[field,value, conditionType],sortOrders, pageSize, etc.  


In my case, I wanted to simulate paginating through all the orders. In other words, I'd want to start by displaying orders with IDs 1-10, then 11-20, and on and on.  


How might I make such a request?


Re: [REST API] Indexes and Lists

Hi @nauce,


Magento 2 API is very easy. You need to use below structure in your URL for search criteria.[filter_groups][0][filters][0][field]=FieldN...


Where "FieldName" is a field of table and "Value" is what value you have to search.

Just to test hit this URL in browser by making Resource as anonymous in webapi.xml.

You will get Output Result in XML format.




Darshan, Solution Consultant
Problem solved? Click Accept as Solution!

Re: [REST API] Indexes and Lists

Hi, in case of "/magento/index.php/rest/V1/search?searchCriteria" I am getting error. The search criteria string is different for this API ?