Site's created via API are not honoring supplied Region value #4565

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

Originally created by @ghost on GitHub (Feb 12, 2021).

Environment

  • Python version: 3.8.7
  • NetBox version: 2.10.4

Steps to Reproduce

  1. Create a Region
  2. Get its ID
  3. Create a Site via the API with the Region ID supplied

requests.post('http://10.1.0.254:8082/api/dcim/sites/',headers={'Authorization':'Token 1234567890abcdef1234567890abcd'},data={'name':'NY1','slug':'site-NY1','region':3,'description':''})

Expected Behavior

A Site would be created and assigned to the supplied Region.

Observed Behavior

The Site was successfully created, but its Region was set to null.

Originally created by @ghost on GitHub (Feb 12, 2021). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for reporting reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, please start a discussion instead: https://github.com/netbox-community/netbox/discussions Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report, and that any plugins have been disabled. --> ### Environment * Python version: 3.8.7 * NetBox version: 2.10.4 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox. Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a client library such as pynetbox. --> ### Steps to Reproduce 1. Create a Region 2. Get its ID 3. Create a Site via the API with the Region ID supplied `requests.post('http://10.1.0.254:8082/api/dcim/sites/',headers={'Authorization':'Token 1234567890abcdef1234567890abcd'},data={'name':'NY1','slug':'site-NY1','region':3,'description':''})` <!-- What did you expect to happen? --> ### Expected Behavior A Site would be created and assigned to the supplied Region. <!-- What happened instead? --> ### Observed Behavior The Site was successfully created, but its Region was set to null.
adam closed this issue 2025-12-29 18:37:43 +01:00
Author
Owner

@ghost commented on GitHub (Feb 13, 2021):

I was able to resolve my issue, but did not want to close the comment in case there was still something to be addressed on the Netbox side. I resolved the issue by simply changing the data parameter in my Python POST request to json.

@ghost commented on GitHub (Feb 13, 2021): I was able to resolve my issue, but did not want to close the comment in case there was still something to be addressed on the Netbox side. I resolved the issue by simply changing the `data` parameter in my Python POST request to `json`.
Author
Owner

@DanSheps commented on GitHub (Feb 22, 2021):

Thank you for your interest in NetBox. GitHub issues are intended for reporting reproducible bugs and requesting features, and must be submitted using one of the templates provided here. For general discussion, questions, or assistance with installation issues, please post to the discussions instead.

@DanSheps commented on GitHub (Feb 22, 2021): Thank you for your interest in NetBox. GitHub issues are intended for reporting reproducible bugs and requesting features, and must be submitted using one of the templates provided [here](https://github.com/netbox-community/netbox/issues/new/choose). For general discussion, questions, or assistance with installation issues, please post to the [discussions](https://github.com/netbox-community/netbox/discussions) instead.
Author
Owner

@ghost commented on GitHub (Feb 22, 2021):

Is that not what I did?

@ghost commented on GitHub (Feb 22, 2021): Is that not what I did?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4565