0

So I'm trying to get started with the Netbox API. However, so far i have been unsuccessful to even recreate simple tutorials. I've created the API user and token.

Here is the basic object creation:

nb = pynetbox.api(url="<myurl>", token="<mytoken>")
nb.http_session.verify = False

Only thing I got to work is print(nb.version). If I try

all_prefixes = nb.ipam.prefixes.all()
print(all_prefixes)

The output is just nothing. If I try

x = nb.dcim.devices.get(1)
print(x)

I get Error 403 - Forbidden ('You do not have permission to perform this action.') Can anyone help me out here? Why is it so hard to make simple requests?

Michele
  • 15
  • 2

1 Answers1

0

You need to grant certain permissions to the user who makes the requests to be able to get devices, prefixes, etc. Go to https://your.netbox.instance/admin/auth/user/, select the user whose token is used for requests and grant certain permissions:

NetBox user permissions

Alternatively, you can make the user superuser so that you don't have to explicitly list the required permissions:

NetBox superuser checbox