Error when trying to use update() on endpoint
See original GitHub issueVersions:
- Python 3.9
- Netbox 3.2.4
- Pynetbox 6.6.2
My code (following almost exactly the documentation):
from pynetbox import api
nb = api(
'https://netbox.local',
token='******************************************'
)
test = nb.dcim.devices.update([
{'id': 1, 'name': 'test'}
])
What I expected:
The device with id 1 should be renamed ‘test’.
What I actually get:
Traceback (most recent call last):
File "/Users/bapth/PyCharm/test-env/nb-test.py", line 8, in <module>
test = nb.dcim.devices.update([
File "/Users/bapth/PyCharm/test-env/.env/lib/python3.9/site-packages/pynetbox/core/endpoint.py", line 374, in update
req = Request(
File "/Users/bapth/PyCharm/test-env/.env/lib/python3.9/site-packages/pynetbox/core/query.py", line 427, in patch
return self._make_call(verb="patch", data=data)
File "/Users/bapth/PyCharm/test-env/.env/lib/python3.9/site-packages/pynetbox/core/query.py", line 287, in _make_call
raise RequestError(req)
pynetbox.core.query.RequestError: The request failed with code 400 Bad Request: {'non_field_errors': ['Expected a list of items but got type "dict".']}
Comments
I get this error since I both updated Netbox and pynetbox. Since my code is using the update function it no longer works. I don’t know if this could change anything but I’m using an Apple M1 chip. I have also tried to update with a list of Record object but it does not work either:
from pynetbox import api
nb = api(
'https://netbox.local',
token='******************************************'
)
devices = nb.dcim.devices.all()
for d in devices:
d.name = d.name + '-test'
test = nb.dcim.devices.update(devices)
Issue Analytics
- State:
- Created a year ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Troubleshoot Windows Defender or Endpoint Protection client
Try to update Windows Defender again. If the issue persists, continue to the next step. Step 2: Make sure that the date and...
Read more >Endpoints not installing updates - Sophos Community
I have about 20 endpoints that are down and can't reach the sus.sophosupd.com. I've ran a trace and it looks like it doesn't...
Read more >Update User details endpoint returns 405, "error": "Method Not ...
I'm trying to update the detail of an existing user in the member table but when I tried to test the endpoint using...
Read more >Troubleshoot Bitdefender Endpoint Security Tools update errors
Error -3 occurs when Bitdefender Endpoint Security cannot download updates over the internet. Possible causes. The error occurs usually when the endpoint cannot ......
Read more >Troubleshooting failed LiveUpdate or definition update issues ...
Use this topic to troubleshoot issues with content updates or LiveUpdate failures on the Symantec agent. If the content is out of date, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I finally found where was my mistake. I did not specify the port of my netbox server when using the api object. By just replacing
with
it all works just fine… Sorry for the useless issue report and thank you again for your kick answer.
Acutally it does add the brackets 🤔 I verified it by adding a
print(data)
in the query.py fileI do get
[{'id': 1, 'name': 'test'}]
in my terminal before raising the error. So I do not really understand where the issue come from 😔