POST api/virtualization/clusters. Can't use name as cluster type. #8753

Closed
opened 2025-12-29 20:40:48 +01:00 by adam · 2 comments
Owner

Originally created by @JaedanC on GitHub (Oct 18, 2023).

NetBox version

v3.6.5-dev

Python version

3.11

Steps to Reproduce

  1. Create a Cluster Type (any name & slug). eg: "My Type" and "my-type"
  2. Use the API to try to create a Cluster using that Cluster Type:

POST /api/virtualization/clusters/

{
    "name": "My VM",
    "type": "My Type",
    "status": "active"
}

The VM will not be created. If you use that exact JSON inside the Cluster "import" in the NetBox gui, the insert will work. Only the API does not. The API only works if you use the Cluster Type's id.

POST /api/virtualization/clusters/

{
    "name": "My VM",
    "type": 5,
    "status": "active"
}

Expected Behavior

You should be able to use the Cluster Type's name (or slug) in the API just like how the import Cluster feature works. There is an inconsistency here.

Observed Behavior

An error code of 400 is returned which means the API request is invalid.

Originally created by @JaedanC on GitHub (Oct 18, 2023). ### NetBox version v3.6.5-dev ### Python version 3.11 ### Steps to Reproduce 1. Create a Cluster Type (any name & slug). eg: "My Type" and "my-type" 2. Use the API to try to create a Cluster using that Cluster Type: `POST /api/virtualization/clusters/` ```json { "name": "My VM", "type": "My Type", "status": "active" } ``` The VM will not be created. If you use that exact JSON inside the Cluster "import" in the NetBox gui, the insert will work. Only the API does not. The API only works if you use the Cluster Type's `id`. `POST /api/virtualization/clusters/` ```json { "name": "My VM", "type": 5, "status": "active" } ``` ### Expected Behavior You should be able to use the Cluster Type's `name` (or `slug`) in the API just like how the import Cluster feature works. There is an inconsistency here. ### Observed Behavior An error code of 400 is returned which means the API request is invalid.
adam closed this issue 2025-12-29 20:40:48 +01:00
Author
Owner

@JaedanC commented on GitHub (Oct 18, 2023):

I have also observed not being able to create/update a cluster assigned to a site by using the site's slug. I must use the site's id as well.

@JaedanC commented on GitHub (Oct 18, 2023): I have also observed not being able to create/update a cluster assigned to a site by using the site's slug. I must use the site's id as well.
Author
Owner

@jeremystretch commented on GitHub (Oct 18, 2023):

This is not a valid format for REST API data. Please consult the documentation for referencing related objects for examples of the supported formats.

@jeremystretch commented on GitHub (Oct 18, 2023): This is not a valid format for REST API data. Please consult the documentation for [referencing related objects](https://docs.netbox.dev/en/stable/integrations/rest-api/#related-objects) for examples of the supported formats.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8753