Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mattburgess opened this issue May 31, 2017 · 2 comments
Closed

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

mattburgess opened this issue May 31, 2017 · 2 comments
Labels
type: bug A confirmed report of unexpected behavior in the application

Comments

@mattburgess
Copy link

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>

@lampwins
Copy link
Contributor

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.

@jeremystretch
Copy link
Member

@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 jeremystretch added the type: bug A confirmed report of unexpected behavior in the application label May 31, 2017
lampwins pushed a commit to lampwins/netbox that referenced this issue Oct 13, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

3 participants