Comments (7)
I can confirm this.
Jun 25 09:54:51 dcim gunicorn[13044]: b'' - - [25/Jun/2018:07:54:51 +0000] "GET //api/dcim/devices/125/ HTTP/1.0" 404 13580 "-" "python-requests/2.10.0"
Removing the extra slash (it's a forward slash, by the way – a backslash is a "\") made it work as predicted:
Jun 25 09:55:58 dcim gunicorn[13044]: b'' - - [25/Jun/2018:07:55:58 +0000] "GET /api/dcim/devices/125/ HTTP/1.0" 200 1986 "-" "python-requests/2.10.0"
from pynetbox.
I'm not sure if I'd call it a bug, though. The example in README.md of pynetbox clearly shows that an ending slash shouldn't be included in the URL. Sure, it happened to work with multiple slashes in succession before, but that is by no means a defined behaviour.
Either make the documentation more explicit in this regard, make pynetbox autodetect and discard any extraneous slashes, or convince the Netbox project to update their API spec to allow for extra slashes. The former alternatives being the better ones, IMHO.
from pynetbox.
I think pynetbox has always raised a RequestError when passed a trailing slash. I've thought about sanitizing the url, but haven't gotten around to it. I tested it on 2.3.3
and 2.3.4
and got it to raise and exception on each, but I also couldn't reproduce the issue. 🤷♂️
from pynetbox.
So I'm not sure what I'm doing wrong and how @konaya was able to
Remove the extra slash
and not encounter the error with v2.3.4
.
I'm not manually add a /
anywhere, the /
gets added automatically by pynetbox
when I do a nb.dcim.sites.get(slug='0am')
from pynetbox.
I'm not sure that pynetbox is adding it. I've tested with the docker image on docker-hub and couldn't reproduce the behavior.
from pynetbox.
Ah, I think I found what I was doing incorrectly.
For my original example for this issue, I was using the following code:
import pynetbox
token = '0123456789abcdef0123456789abcdef01234567'
test_url = 'http://node2.internal:10123/'
node_url = 'http://node3.internal:10123/'
nb_url = test_url
nb = pynetbox.api(nb_url,token)
This worked fine for all versions of NetBox
through v2.3.3
, however, in v2.3.4
, I had to remove the trailing forward slash (/
) from the end of the url
:
import pynetbox
token = '0123456789abcdef0123456789abcdef01234567'
test_url = 'http://node2.internal:10123'
node_url = 'http://node3.internal:10123'
nb_url = test_url
nb = pynetbox.api(nb_url,token)
After I made that change, everything started to work fine once again.
Like @konaya said, the README.md of pynetbox
does show the url
without the trailing slash, however I don't know that I would call it clearly :)
@zachmoody I think it would be a good idea to either, (1) sanitize it like you mentioned wanting to or (2) updating the documentation to make it clear that including the trailing /
might cause problems.
from pynetbox.
Yeah, I'd like to sanitize the input. I'll leave this issue open to track that.
from pynetbox.
Related Issues (20)
- No longer works with Netbox as of v3.5.0 due to OpenAPI change HOT 2
- Pynetbox 7 fails to create circuit with Netbox 3.5. due to provider_account required HOT 1
- ObjectChanges Log is calling the wrong API endpoint HOT 2
- Cables.serialize() is inconsistent
- virtual-device-context save() is using wrong API endpoint = missing support for VDCs in v7.0.1? HOT 1
- netbox ipam create ip address doesnot work
- 500 Internal Server Error when creating custom field
- I suspect that when filtering VLANS, the Exception is not Raised on an error message. HOT 2
- Incompatible Exception usage HOT 9
- Tests failing
- pynetbox import error importlib.metdata python3.6 HOT 3
- Add support for NetBox v3.6 HOT 1
- readthedocs doesn't show endpoints like DCIM
- Device object has no attribute "render_config" HOT 1
- Can't reset object attribute to its initial value.
- render_config tries wrong url when Netbox is behind reverse proxy HOT 1
- Choices are not returned when the API token can PUT but not POST on an endpoint HOT 4
- Keep getting Connection Reset HOT 2
- Add `vpn` app for NetBox 3.7 compatibility
- pynetbox greater than 7.0.0 fails to insert complex custom_fields HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pynetbox.