magedin / module-enhanced-api-search
Enhances to Magento 2 API Search
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:magento2-module
Requires
- magento/framework: *
- magento/module-webapi: *
This package is auto-updated.
Last update: 2024-10-15 21:57:01 UTC
README
This module introduces a new way to search in Magento 2 API. Rather than using a querystring, use the body with the JSON format for creating your searchCriteria
parameters.
What this module was created for?
A typical search in Magento 2 API is done by putting all the parameters in a querystring, like below:
curl -X GET https://my-magento2.com/rest/V1/orders/?searchCriteria[currentPage]=1&searchCriteria[filterGroups][0][filters][0][field]=increment_id&searchCriteria[filterGroups][0][filters][0][value]=610001259&searchCriteria[filterGroups][0][filters][0][conditionType]=eq
Building this querystring on Postman, is like below:
Well, it can confuse a little and, actually, I always forget how to build these parameters.
This module allows you to use the most simplified URL:
https://my-magento2.com/rest/V1/orders/
With the following body parameters:
{ "searchCriteria": { "pageSize": 20, "currentPage": 1, "filterGroups": [ { "filters": [ { "conditionType": "eq", "field": "increment_id", "value": "000000002" } ] } ] } }
Simple, right?
Wait!! Body params in a GET Request?
Yes, I understand this may be a kinda weird, bring some confusion to our heads or even issues with cache systems, for instance, but the module is really simple to not be done. If it fits your needs, feel free to use it without costs.
But if you are very strict with the rules, you don't need to use it.
Reference: https://www.rfc-editor.org/rfc/rfc2616