Unable to filter device types by manufacturer name #4234

Closed
opened 2025-12-29 18:34:10 +01:00 by adam · 3 comments
Owner

Originally created by @larsks on GitHub (Nov 1, 2020).

Environment

  • Python version: Python 3.8
  • NetBox version: 2.9

Steps to Reproduce

I am trying to filter devices-types by manufacturer. According to the API docs, GET /dcim/device-types/ supports both manufacturer (a string) and manufacturer_id (an integer) as query parameters. Querying by manufacturer id seems to work:

$ http  "${NETBOX_URL}/api/dcim/device-types/?manufacturer_id=2"   "Authorization:Token $NETBOX_TOKEN"
HTTP/1.1 200 OK
[...]

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
            [...]
            "manufacturer": {
                "id": 2,
                "name": "Dell Inc.",
                "slug": "dell-inc",
                "url": "http://netbox-moc-ops.apps.example.com/api/dcim/manufacturers/2/"
            },
            [...]
    ]
}

But attempting to query by manufacturer name fails:

$ http  "${NETBOX_URL}/api/dcim/device-types/?manufacturer=Dell+Inc."   "Authorization:Token $NETBOX_TOKEN"
HTTP/1.1 400 Bad Request
[...]

{
    "manufacturer": [
        "Select a valid choice. Dell Inc. is not one of the available choices."
    ]
}

Expected Behavior

I expected to be able to filter the list of device types by manufacturer name.

Observed Behavior

Netbox returned a 400 status with the error message described above.

Originally created by @larsks on GitHub (Nov 1, 2020). ### Environment * Python version: Python 3.8 * NetBox version: 2.9 ### Steps to Reproduce I am trying to filter `devices-types` by `manufacturer`. According to [the API docs](https://netboxdemo.com/api/docs/), `GET /dcim/device-types/` supports both `manufacturer` (a string) and `manufacturer_id` (an integer) as query parameters. Querying by manufacturer id seems to work: ``` $ http "${NETBOX_URL}/api/dcim/device-types/?manufacturer_id=2" "Authorization:Token $NETBOX_TOKEN" HTTP/1.1 200 OK [...] { "count": 1, "next": null, "previous": null, "results": [ [...] "manufacturer": { "id": 2, "name": "Dell Inc.", "slug": "dell-inc", "url": "http://netbox-moc-ops.apps.example.com/api/dcim/manufacturers/2/" }, [...] ] } ``` But attempting to query by manufacturer name fails: ``` $ http "${NETBOX_URL}/api/dcim/device-types/?manufacturer=Dell+Inc." "Authorization:Token $NETBOX_TOKEN" HTTP/1.1 400 Bad Request [...] { "manufacturer": [ "Select a valid choice. Dell Inc. is not one of the available choices." ] } ``` <!-- What did you expect to happen? --> ### Expected Behavior I expected to be able to filter the list of device types by manufacturer name. <!-- What happened instead? --> ### Observed Behavior Netbox returned a 400 status with the error message described above.
adam closed this issue 2025-12-29 18:34:10 +01:00
Author
Owner

@larsks commented on GitHub (Nov 1, 2020):

Apparently I can query by manufacturer_name, although that doesn't show up in the API documentation:

$ http  "${NETBOX_URL}/api/dcim/device-types/?manufacturer_name=Dell+Inc."   "Authorization:Token $NETBOX_TOKEN"
HTTP/1.1 200 OK
[...]

{
    [...]
    "results": [
        {
            [...]
            "manufacturer": {
                "id": 2,
                "name": "Dell Inc.",
                "slug": "dell-inc",
                "url": "http://netbox-moc-ops.apps.example.com/api/dcim/manufacturers/2/"
            },
            [...]
        }
    ]
}

I'm not sure if this is a documentation problem, or if I'm just failing to read the API docs correct?

@larsks commented on GitHub (Nov 1, 2020): Apparently I can query by `manufacturer_name`, although that doesn't show up in the API documentation: ``` $ http "${NETBOX_URL}/api/dcim/device-types/?manufacturer_name=Dell+Inc." "Authorization:Token $NETBOX_TOKEN" HTTP/1.1 200 OK [...] { [...] "results": [ { [...] "manufacturer": { "id": 2, "name": "Dell Inc.", "slug": "dell-inc", "url": "http://netbox-moc-ops.apps.example.com/api/dcim/manufacturers/2/" }, [...] } ] } ``` I'm not sure if this is a documentation problem, or if I'm just failing to read the API docs correct?
Author
Owner

@jeremystretch commented on GitHub (Nov 5, 2020):

The manufacturer filter matches on the manufacturer's slug, not the human-friendly name, so you want e.g. ?manufacturer=dell-inc. Please post to the mailing list if you require any further assistance.

@jeremystretch commented on GitHub (Nov 5, 2020): The `manufacturer` filter matches on the manufacturer's slug, not the human-friendly name, so you want e.g. `?manufacturer=dell-inc`. Please post to the mailing list if you require any further assistance.
Author
Owner

@larsks commented on GitHub (Nov 5, 2020):

There appears to be a doc bug, since the api docs only mention manufacturer and manufacturer_id. I'd offer to fix it, but you've closed the issue and suggested there's not a problem, so maybe you disagree.

@larsks commented on GitHub (Nov 5, 2020): There appears to be a doc bug, since the api docs only mention `manufacturer` and `manufacturer_id`. I'd offer to fix it, but you've closed the issue and suggested there's not a problem, so maybe you disagree.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4234