import requests
url = 'https://<hostname>/api/dcim/sites'
data = {"name" : "my new site" , "slug" : "my-new-site"}
headers = {'X-CSRFToken': 'f8581ac22fca6067a3f15b8a3227138f08e8', 'Content-Type': 'application/json', 'Accept': 'application/json'}
response = requests.post(url, json=data, headers=headers, verify=False)
import requests
url = 'https://netbox-sf-1.mdtmi.org/api/dcim/sites'
data = {"name" : "my new site" , "slug" : "my-new-site"}
headers = {'Authorization': 'Token f8581ac22fca6067a3f15b8a3227138f08e8', 'Content-Type': 'application/json', 'Accept': 'application/json'}
response = requests.post(url, json=data, headers=headers, verify=False)
apiurl = "http://netbox/api/dcim/sites/%s/" % siteid
payload = "{ \"name\":\"%s\", \"slug\":\"%s\", \"asn\":\"%s\" }" % (store, store, bgp_as)
r2 = requests.put(apiurl, headers={"Authorization": "Token aaaadddd", "Content-Type": "application/json"}, data=payload)
print r2.status_code
--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to netbox-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/4936b11a-d4b2-4f9b-8c04-5ac2f8c88a5f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Here's a small snippet that I use...whats your response.status_code after the request?apiurl = "http://netbox/api/dcim/sites/%s/" % siteid
payload = "{ \"name\":\"%s\", \"slug\":\"%s\", \"asn\":\"%s\" }" % (store, store, bgp_as)
r2 = requests.put(apiurl, headers={"Authorization": "Token aaaadddd", "Content-Type": "application/json"}, data=payload)
print r2.status_code
On Thu, Aug 17, 2017 at 10:27 AM, Craig <craig.sl...@gmail.com> wrote:
I'm trying the following via a python script, but it is not working for me. Is netbox designed to accept posts to the API with anything other than curl? Am I missing something? I've also tried using data=data instead of json=data
import requests
url = 'https://<hostname>/api/dcim/sites'
data = {"name" : "my new site" , "slug" : "my-new-site"}
headers = {'X-CSRFToken': 'f8581ac22fca6067a3f15b8a3227138f08e8', 'Content-Type': 'application/json', 'Accept': 'application/json'}
response = requests.post(url, json=data, headers=headers, verify=False)
I've also tried it this way:
import requests
url = 'https://netbox-sf-1.mdtmi.org/api/dcim/sites'
data = {"name" : "my new site" , "slug" : "my-new-site"}
headers = {'Authorization': 'Token f8581ac22fca6067a3f15b8a3227138f08e8', 'Content-Type': 'application/json', 'Accept': 'application/json'}
response = requests.post(url, json=data, headers=headers, verify=False)
--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To post to this group, send email to netbox-...@googlegroups.com.
Here's a small snippet that I use...whats your response.status_code after the request?apiurl = "http://netbox/api/dcim/sites/%s/" % siteid
payload = "{ \"name\":\"%s\", \"slug\":\"%s\", \"asn\":\"%s\" }" % (store, store, bgp_as)
r2 = requests.put(apiurl, headers={"Authorization": "Token aaaadddd", "Content-Type": "application/json"}, data=payload)
print r2.status_code
On Thu, Aug 17, 2017 at 10:27 AM, Craig <craig.sl...@gmail.com> wrote:
I'm trying the following via a python script, but it is not working for me. Is netbox designed to accept posts to the API with anything other than curl? Am I missing something? I've also tried using data=data instead of json=data
import requests
url = 'https://<hostname>/api/dcim/sites'
data = {"name" : "my new site" , "slug" : "my-new-site"}
headers = {'X-CSRFToken': 'f8581ac22fca6067a3f15b8a3227138f08e8', 'Content-Type': 'application/json', 'Accept': 'application/json'}
response = requests.post(url, json=data, headers=headers, verify=False)
I've also tried it this way:
import requests
url = 'https://netbox-sf-1.mdtmi.org/api/dcim/sites'
data = {"name" : "my new site" , "slug" : "my-new-site"}
headers = {'Authorization': 'Token f8581ac22fca6067a3f15b8a3227138f08e8', 'Content-Type': 'application/json', 'Accept': 'application/json'}
response = requests.post(url, json=data, headers=headers, verify=False)
--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To post to this group, send email to netbox-...@googlegroups.com.