API returning 200 on POST, not saving new object #1180

Closed
opened 2025-12-29 16:29:48 +01:00 by adam · 1 comment
Owner

Originally created by @cslingerland on GitHub (Aug 17, 2017).

Issue type:

**Python version: 2.7
**NetBox version: latest

I'm using the following code in a python script to try and post to the API with no luck. Is this an issue with the system?

import requests

url = 'https://hostname/api/dcim/sites'
data = {"name" : "my new site" , "slug" : "my-new-site"}
headers = {'Authorization': 'Token f8581ac22fca6067ad1fa65sd1fa561c57138f08e8', 'Content-Type': 'application/json', 'Accept': 'application/json; indent=4'}
response = requests.post(url, json=data, headers=headers, verify=False)
Originally created by @cslingerland on GitHub (Aug 17, 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: <!-- 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 **NetBox version: latest I'm using the following code in a python script to try and post to the API with no luck. Is this an issue with the system? ``` import requests url = 'https://hostname/api/dcim/sites' data = {"name" : "my new site" , "slug" : "my-new-site"} headers = {'Authorization': 'Token f8581ac22fca6067ad1fa65sd1fa561c57138f08e8', 'Content-Type': 'application/json', 'Accept': 'application/json; indent=4'} response = requests.post(url, json=data, headers=headers, verify=False) ``` <!-- 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. -->
adam closed this issue 2025-12-29 16:29:48 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 17, 2017):

GitHub issues are intended for reporting bugs and requesting features. For general discussion or assistance with installation issues, please post to our mailing list.

@jeremystretch commented on GitHub (Aug 17, 2017): GitHub issues are intended for reporting bugs and requesting features. For general discussion or assistance with installation issues, please post to our [mailing list](https://groups.google.com/forum/#!forum/netbox-discuss).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1180