HTTP 500 when adding a VLAN Group with Site via API #1003

Closed
opened 2025-12-29 16:27:45 +01:00 by adam · 2 comments
Owner

Originally created by @mattburgess on GitHub (May 31, 2017).

Issue type: bug report

Python version: 2.7.5
NetBox version: 2.0.4

Adding a VLAN Group via the API works fine, so long as I don't specify a 'site':

curl -X POST -H "Authorization: Token $token" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" http://$netbox_host/api/ipam/vlan-groups/ --data '{"name": "VG1", "slug": "vg1"}'

However, if I specify a site ID in the data payload, I get an HTTP 500 error back:

curl -X POST -H "Authorization: Token $token" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" http://$netbox_host/api/ipam/vlan-groups/ --data '{"name": "VG1", "slug": "vg1", "site": "19"}'

The error message is:

<pre><strong>&lt;class &#39;django.core.exceptions.FieldError&#39;&gt;</strong><br /> Cannot resolve keyword &#39;slug&#39; into field. Choices are: created, custom_field_values, description, group, group_id, id, last_updated, name, prefixes, role, role_id, site, site_id, status, tenant, tenant_id, vid</pre>

Originally created by @mattburgess on GitHub (May 31, 2017). <!-- Please note: GitHub issues are to be used only for feature requests and bug reports. For installation assistance or general discussion, please join us on the mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please indicate "bug report" or "feature request" below. Be sure to search the existing set of issues (both open and closed) to see if a similar issue has already been raised. --> ### Issue type: bug report <!-- If filing a bug, please indicate the version of Python and NetBox you are running. (This is not necessary for feature requests.) --> **Python version:** 2.7.5 **NetBox version:** 2.0.4 <!-- If filing a bug, please record the exact steps taken to reproduce the bug and any errors messages that are generated. If filing a feature request, please precisely describe the data model or workflow you would like to see implemented, and provide a use case. --> Adding a VLAN Group via the API works fine, so long as I don't specify a 'site': `curl -X POST -H "Authorization: Token $token" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" http://$netbox_host/api/ipam/vlan-groups/ --data '{"name": "VG1", "slug": "vg1"}'` However, if I specify a site ID in the data payload, I get an HTTP 500 error back: `curl -X POST -H "Authorization: Token $token" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" http://$netbox_host/api/ipam/vlan-groups/ --data '{"name": "VG1", "slug": "vg1", "site": "19"}'` The error message is: `<pre><strong>&lt;class &#39;django.core.exceptions.FieldError&#39;&gt;</strong><br /> Cannot resolve keyword &#39;slug&#39; into field. Choices are: created, custom_field_values, description, group, group_id, id, last_updated, name, prefixes, role, role_id, site, site_id, status, tenant, tenant_id, vid</pre>`
adam added the type: bug label 2025-12-29 16:27:45 +01:00
adam closed this issue 2025-12-29 16:27:45 +01:00
Author
Owner

@lampwins commented on GitHub (May 31, 2017):

You are passing the site ID as the site parameter which is expecting a slug. You need to pass your ID in the site_id parameter.

@lampwins commented on GitHub (May 31, 2017): You are passing the site ID as the `site` parameter which is expecting a slug. You need to pass your ID in the `site_id` parameter.
Author
Owner

@jeremystretch commented on GitHub (May 31, 2017):

@lampwins You may be thinking of the filters, where site takes a slug and site_id takes a primary key. The API calls @MattBurgess posted are both correct.

There's a bug in the serializer validation that's preventing a VLANGroup from being created if a site is assigned.

@jeremystretch commented on GitHub (May 31, 2017): @lampwins You may be thinking of the filters, where `site` takes a slug and `site_id` takes a primary key. The API calls @MattBurgess posted are both correct. There's a bug in the [serializer validation](https://github.com/digitalocean/netbox/blob/develop/netbox/ipam/api/serializers.py#L135) that's preventing a VLANGroup from being created if a site is assigned.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1003