Exception raised when passing a dictionary value to an API ChoiceField #2201

Closed
opened 2025-12-29 17:23:33 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Dec 11, 2018).

Environment

  • Python version: 3.5.2
  • NetBox version: 2.5.0

Steps to Reproduce

Issue the following API request to create a new prefix:

curl -X POST \
-H "Authorization: Token <TOKEN>" \
-H "Content-Type: application/json" \
-H "Accept: application/json; indent=4" \
http://<NETBOX>/api/ipam/prefixes/ \
--data '{"prefix": "192.0.2.0/24", "status": {"foo": "bar"}}'

Expected Behavior

The API response should indicate an invalid value for status.

Observed Behavior

An exception is raised:

TypeError: int() argument must be a string, a bytes-like object or a number, not 'dict'
Originally created by @jeremystretch on GitHub (Dec 11, 2018). ### Environment * Python version: 3.5.2 * NetBox version: 2.5.0 ### Steps to Reproduce Issue the following API request to create a new prefix: ``` curl -X POST \ -H "Authorization: Token <TOKEN>" \ -H "Content-Type: application/json" \ -H "Accept: application/json; indent=4" \ http://<NETBOX>/api/ipam/prefixes/ \ --data '{"prefix": "192.0.2.0/24", "status": {"foo": "bar"}}' ``` ### Expected Behavior The API response should indicate an invalid value for `status`. ### Observed Behavior An exception is raised: ``` TypeError: int() argument must be a string, a bytes-like object or a number, not 'dict' ```
adam added the type: bugstatus: accepted labels 2025-12-29 17:23:33 +01:00
adam closed this issue 2025-12-29 17:23:34 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2201