KeyError when creating rack via API with width as string #2142

Closed
opened 2025-12-29 17:22:38 +01:00 by adam · 1 comment
Owner

Originally created by @Loopbackconnector on GitHub (Nov 23, 2018).

Environment

  • Python version: 3.5.3
  • NetBox version: v2.5 Beta1

Steps to Reproduce

curl -X POST -H "Authorization: Token <token>" -H "Content-Type: application/json" -H"Accept: application/json; indent=4" http://netbox.server.com/api/dcim/racks/ --data '{"site": 1, "name": "My New Rack", "width": "19", "u_height": "42"}'

Expected Behavior

Expected a successful post

Observed Behavior

Object created even though error. Also Error is not descriptive as to what the issue is.

<pre><strong>&lt;class &#39;KeyError&#39;&gt;</strong><br />
&#39;19&#39;</pre>
</html>
Originally created by @Loopbackconnector on GitHub (Nov 23, 2018). <!-- NOTE: This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.5.3 * NetBox version: v2.5 Beta1 <!-- Describe in detail the steps that someone else can take to reproduce this bug using the current stable release of NetBox (or the current beta release where applicable). --> ### Steps to Reproduce ``` curl -X POST -H "Authorization: Token <token>" -H "Content-Type: application/json" -H"Accept: application/json; indent=4" http://netbox.server.com/api/dcim/racks/ --data '{"site": 1, "name": "My New Rack", "width": "19", "u_height": "42"}' ``` <!-- What did you expect to happen? --> ### Expected Behavior Expected a successful post <!-- What happened instead? --> ### Observed Behavior Object created even though error. Also Error is not descriptive as to what the issue is. ``` <pre><strong>&lt;class &#39;KeyError&#39;&gt;</strong><br /> &#39;19&#39;</pre> ``` </html>
adam added the type: bugstatus: accepted labels 2025-12-29 17:22:38 +01:00
adam closed this issue 2025-12-29 17:22:38 +01:00
Author
Owner

@jeremystretch commented on GitHub (Nov 26, 2018):

This is happening because the width value is being passed as a string rather than an integer. NetBox should still accept it, but for an immediate solution, simply remove the quotes around the value:

'{"site": 1, "name": "My New Rack", "width": 19, "u_height": 42}'
@jeremystretch commented on GitHub (Nov 26, 2018): This is happening because the `width` value is being passed as a string rather than an integer. NetBox should still accept it, but for an immediate solution, simply remove the quotes around the value: ``` '{"site": 1, "name": "My New Rack", "width": 19, "u_height": 42}' ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2142