cancel
Showing results for 
Search instead for 
Did you mean: 

Rest Api list of attributes Groups

Rest Api list of attributes Groups

Hello everyone, I'm trying to pull out the list of all the attributes groups via REST API, but I have a problem with your request, you can explain how to do, because with my request via url I always get this error:

 

$this->url = 'http://www,magentotest.it/';
$action = 'V1/products/attribute-sets/groups/list';
$link = $this->url.$action.'?&searchCriteria[filterGroups][0][filters][0][field]=attributeSetId&searchCriteria[filterGroups][0][filters][0][value]='.$setId.'&searchCriteria[filter_groups][0][filters][0][condition_type]=eq';

Documentation indicates this:

 

{
  "items": [
    {
      "attributeGroupId": "string",
      "attributeGroupName": "string",
      "attributeSetId": 0,
      "extensionAttributes": {}
    }
  ],
  "searchCriteria": {
    "filterGroups": [
      {
        "filters": [
          {
            "field": "string",
            "value": "string",
            "conditionType": "string"
          }
        ]
      }
    ],
    "sortOrders": [
      {
        "field": "string",
        "direction": "string"
      }
    ],
    "pageSize": 0,
    "currentPage": 0
  },
  "totalCount": 0
}

This is the error that comes back to me:

object(stdClass)#483 (2) { ["message"]=> string(31) "%fieldName is a required field." ["parameters"]=> object(stdClass)#484 (1) { ["fieldName"]=> string(16) "attribute_set_id" } }

Can someone help me?
Thank you

Tags (1)
4 REPLIES

Re: Rest Api list of attributes Groups

Please Pass like below 

 

rest/V1/products/attribute-sets/groups/list?&searchCriteria[filterGroups][0][filters][0][field]=attribute_set_id&searchCriteria[filterGroups][0][filters][0][value]=4 

 

 

you will get the result.

Re: Rest Api list of attributes Groups

As of version 2.1.X it has to be used like this:

 

searchCriteria[filter_groups][0][filters][0][field]=attribute_set_id&searchCriteria[filter_groups][0][filters][0][value]=4

 

Don't camelcase the parameters.  Not sure why it changed, but if you are getting an error like 

 

{
"message": "Invalid signature"
}

 

Then, you have the casing wrong.  Theres really nothing wrong with the signature. Go figure.

Re: Rest Api list of attributes Groups

Re: Rest Api list of attributes Groups

Ok, so I have been banging my head against the wall with this same problem for a while, and it seems that the API is just plain bad.

 

Considering the API route, which accepts the standard searchCriteria parameters:

GET /V1/products/attribute-sets/groups/list

 

Based on the definition in the spec and the limited documentation, one would expect that this would allow for searching across all attribute groups, or to simply get a list of all attribute groups that are defined within the system, but it in fact only allows for listing all attributes that belong to a particular attribute set.  The "search parameters" are not really search parameters and only work if set as

 

 

 

searchCriteria[filterGroups][0][filters][0][field]=attribute_set_id
searchCriteria[filterGroups][0][filters][0][value]={{SOME_ATTRIBUTE_SET_ID}}

 

 

Any other parameters seem to be ignored and are meaningless.

 

There is a PUT route like /V1/products/attribute-sets/{attributeSetId}/groups that would really be a better path for this call, as it follows a more meaningful collection/resource REST model, but alas, that is not how the world is as of Magento 2.2