Skip to main content
Solved

How to use v3 API to get categories usage details

  • Dec 29, 2020 4:29 PM UTC
  • 6 replies
  • 3170 views

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

Best answer by Alona

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":["Production"]}
  },
  "api_version": "3.1.0"
}

View original
This topic has been closed for replies.

6 replies

AnishWalia20
Nutanix Employee
Forum|alt.badge.img+5
  • Nutanix Employee
  • Dec 31, 2020 7:03 AM UTC

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.


  • Adventurer
  • Jan 26, 2021 5:44 AM UTC

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.


  • Adventurer
  • Jan 26, 2021 7:14 AM UTC

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": ["Production"]
    }
  },
  "api_version": "3.1.0"
}

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


Alona
Nutanix Employee
Forum|alt.badge.img+5
  • Nutanix Employee
  • Answer
  • Jan 27, 2021 3:02 AM UTC

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":["Production"]}
  },
  "api_version": "3.1.0"
}


  • Adventurer
  • Jan 27, 2021 6:25 PM UTC

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


Alona
Nutanix Employee
Forum|alt.badge.img+5
  • Nutanix Employee
  • Jan 27, 2021 10:40 PM UTC

Glad it helped:)