"curl -X GET --header 'Accept: application/json' 'http://localhost/api/dcim/interfaces/"import requests
import json
url='http://localhost/api/dcim/devices/2/napalm/?format=json&method=get_interfaces'
cookies = dict(sessionid='my id')
r = requests.get(url, cookies)
r.json()It requires the authentication? (Because API returns 403.)https://netbox.readthedocs.io/en/latest/api/authentication/Regards,
Makkie
2018/02/22 16:29、VK <kayu...@gmail.com>のメール:
Hello! I apologize for my bad English.I'm studying your API and I'm having trouble getting information from the API on the command line.When I use a API netbox, all requests work correctly. For example:"curl -X GET --header 'Accept: application/json' 'http://localhost/api/dcim/interfaces/"However, if I want to add napalm API, I do not get any data on the command line. In this case everything works correctly in the browser.I'm trying to get information about the interfaces of the device:If I'm logged into the netbox in the browser, everything works correctly. At the command prompt, I get an empty response and an error of 403. I tried to do this with a python and found out that this was related to authorization. If I add an id cookie session I get all the data and it works.import requests
import json
url='http://localhost/api/dcim/devices/2/napalm/?format=json&method=get_interfaces'
cookies = dict(sessionid='my id')
r = requests.get(url, cookies)
r.json()I get the session ID with the help of the wireshark.Unfortunately I can not understand how I get data on the command line (or python) and what I'm doing is wrong. Thank you.--
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/cc558dd6-66f2-48fa-b566-6aa7b1cc50da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/FFE1EE8F-A1E2-4A67-B22D-7CCBAD048646%40gmail.com.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.