How to use v3 API to get categories usage details | Nutanix Community
Skip to main content

Hi

I’m using Nutanix Prism Central v3 API and I want to run the API call referenced here:

https://www.nutanix.dev/reference/prism_central/v3/api/categories/postcategoryquery/

to get the category information.

I’m calling this API: https://<prism_ip>:9440/api/nutanix/v3/category/query, using Postman. My problem is filling the request body.

 

The example at the bottom of the page shows this request body:

{
  "api_version": "3.1.0",
  "group_member_count": 123,
  "group_member_offset": 123,
  "usage_type": "string",
  "category_filter": {
    "type": "CATEGORIES_MATCH_ANY",
    "kind_list":
      "string"
    ],
    "params": {}
  }
}

 

But the params property is empty and I can’t figure out how to fill it properly.

It says in the description that it’s supposed to have “a list of category key and list of values”, but no matter what I try I either get an error regarding the json structure or this error: For a search specify the correct usage type.

 

Can someone please provide an example of how to use this API call fully? Specifically how to fill the params property in the request body?

 

 

Thanks

Hey @Matan Here is the documentation for using this API https://www.nutanix.dev/reference/prism_central/v3/api/categories/postcategoryquery/

 

All the information related to APIs, v2,v3 and code samples can be found here https://www.nutanix.dev/api-reference/

 

I hope this helps you mate. :sweat_smile:

 

Let me know if I can help in any other way.


Same question here. It doesn’t look like the question was fully answered. The API links @AnishWalia20  referenced do not provide an example of the params required as the original question was alluding to.


Sorry, was not allowed to edit previous reply so adding another.

I got a little further by including usage_type that was indicated as optional. This got me past the WRONG_CATEGORY_USAGE_TYPE error, but still did not get any matches. I have category Environment:Production assigned to 4 VMs entities, so expected 4 matches. Any suggestion?

Body:
{
  "usage_type": "APPLIED_TO",
  "group_member_count": 500,
  "category_filter": {
    "type": "CATEGORIES_MATCH_ANY",
    "params": {
        "name": "Environment"],        
        "values": b"Production"]
    }
  },
  "api_version": "3.1.0"
}

Result:
{
  "results": p],
  "api_version": "3.1",
  "metadata": {
    "total_matches": 0,
    "usage_type": "APPLIED_TO",
    "group_member_offset": 0,
    "group_member_count": 500
  }
}


Hi Jesus Lopez,

Try this:
{
  "usage_type": "APPLIED_TO",
  "group_member_offset": 0,
  "group_member_count": 0,
  "category_filter": {
    "type": "CATEGORIES_MATCH_ANY",
    "params": {"Environment":i"Production"]}
  },
  "api_version": "3.1.0"
}


Thank you @Alona, your recommendation has resolved my issue.


Glad it helped:)