VMware NSX

  • 1.  NSX-T API adding group

    Posted Sep 26, 2022 08:59 PM

    I am trying to add a group into the inventory as I see on the web interface using the REST API:

    PUT /global-manager/api/v1/global-infra/domains/default/groups

    {
    "expression" : [ {
    "ip_addresses" : [ "1.1.1.1" ],
    "resource_type" : "IPAddressExpression"
    } ],
    "resource_type" : "Group",
    "display_name" : "00test11",
    "description" : "test api call",
    "_system_owned" : false,
    "_protection" : "NOT_PROTECTED",
    "_revision" : 0
    }

     

    I keep getting the response:
    { "module_name" : "common-services",

    "error_message" : "Method is not allowed",

    "error_code" : 282 }

     

    When I do GET /global-manager/api/v1/global-infra/domains/default/groups, I do get all the groups. is there a step that I am missing before making a PUT method call? the docs mention put PUT /global-manager/api/v1/global-infra/domains/default/groups/<group-id> but how do I get the <group-id> before I create it? Any help would be appreciated.



  • 2.  RE: NSX-T API adding group

    Posted Sep 27, 2022 02:42 AM

    Hi,

    if you are creating a new group based on IP address Expression, display name "00test11" is going to group-id. Try like this 

    PUT /global-manager/api/v1/global-infra/domains/default/groups/00test11

    https://developer.vmware.com/apis/1230/nsx-t-global-manager

     

    HTH

    Sandy

     

     



  • 3.  RE: NSX-T API adding group

    Posted Sep 27, 2022 01:50 PM

    I have tried that by following the URL mentioned in the docs as you described and then the error comes back as:

    { "httpStatus" : "NOT_FOUND",

    "error_code" : 500090,

    "module_name" : "Policy", "error_message" : "Policy object path=[/global-infra/domains/default/groups/00test11] does not exist." }



  • 4.  RE: NSX-T API adding group
    Best Answer

    Posted Sep 27, 2022 02:06 PM

    So, after being stuck on this issue for long with no success, I tried to use method PATCH and use the URL ..domains/default/groups/00test11 and that works!



  • 5.  RE: NSX-T API adding group

    Posted Mar 28, 2025 01:27 PM

    I have the same issue, but I have hundreds of groups to create as part of a migration from a non-VCF environment to a new VCF environment. I can export all the groups from the source NSX Manager and they are formatted just like the JSON input @salmanksfu posted in his initial query (with additional details).
    The PATCH method will not work for me, as the URL would have to be unique for every API call and if I have to use unique URLs every time, I might as well manually recreate the groups.

    The documentation clearly states that the PUT call should work, so I don't understand why I get a 'Method is not allowed' error. It doesn't matter whether I try this against the GM or LM, I get the same results.