Skip to main content
Solved

How to use v3 API to get categories usage details

  • December 29, 2020
  • 6 replies
  • 2881 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"
}

This topic has been closed for replies.

6 replies

AnishWalia20
Nutanix Employee
Forum|alt.badge.img+5
  • Nutanix Employee
  • 178 replies
  • December 31, 2020

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
  • 3 replies
  • January 26, 2021

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
  • 3 replies
  • January 26, 2021

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
  • 426 replies
  • Answer
  • January 27, 2021

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
  • 3 replies
  • January 27, 2021

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


Alona
Nutanix Employee
Forum|alt.badge.img+5
  • Nutanix Employee
  • 426 replies
  • January 27, 2021

Glad it helped:)