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 "http://mage2.dev/index.php/rest/V1/orders" \ -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?
Hi @nauce,
Magento 2 API is very easy. You need to use below structure in your URL for search criteria.
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.
Hi, in case of "/magento/index.php/rest/V1/search?searchCriteria" I am getting error. The search criteria string is different for this API ?