IP Address Role not accepting null value when parsing a JSON file #1842

Closed
opened 2025-12-29 17:19:40 +01:00 by adam · 5 comments
Owner

Originally created by @JSystem1 on GitHub (Jul 13, 2018).

Issue type

[ ] Feature request
[X] Bug report
[ ] Documentation
[ ] Housekeeping

Environment

  • Python version: 2.6
  • NetBox version: 2.3.2

Description

So it seems when you parse a empty role at the endpoint /ipam/ip-addresses/ using a JSON file to parse it returns with the following error:
[{u'role': [u'"" is not a valid choice.']}]

When doing just a normal API call this is allowed/bypassed by filling in the role value as null. I need to keep the role value when parsing due to some rows not being empty.

I have tried to fill the NaN rows with "null" but it returns the same error as above

Originally created by @JSystem1 on GitHub (Jul 13, 2018). <!-- Before opening a new issue, please search through the existing issues to see if your topic has already been addressed. Note that you may need to remove the "is:open" filter from the search bar to include closed issues. Check the appropriate type for your issue below by placing an x between the brackets. For assistance with installation issues, or for any other issues other than those listed below, please raise your topic for discussion on our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please note that issues which do not fall under any of the below categories will be closed. Due to an excessive backlog of feature requests, we are not currently accepting any proposals which extend NetBox's feature scope. Do not prepend any sort of tag to your issue's title. An administrator will review your issue and assign labels as appropriate. ---> ### Issue type [ ] Feature request <!-- An enhancement of existing functionality --> [X] Bug report <!-- Unexpected or erroneous behavior --> [ ] Documentation <!-- A modification to the documentation --> [ ] Housekeeping <!-- Changes pertaining to the codebase itself --> <!-- Please describe the environment in which you are running NetBox. (Be sure to verify that you are running the latest stable release of NetBox before submitting a bug report.) If you are submitting a bug report and have made any changes to the code base, please first validate that your bug can be recreated while running an official release. --> ### Environment * Python version: 2.6 * NetBox version: 2.3.2 <!-- BUG REPORTS must include: * A list of the steps needed for someone else to reproduce the bug * A description of the expected and observed behavior * Any relevant error messages (screenshots may also help) FEATURE REQUESTS must include: * A detailed description of the proposed functionality * A use case for the new feature * A rough description of any necessary changes to the database schema * Any relevant third-party libraries which would be needed --> ### Description So it seems when you parse a empty role at the endpoint `/ipam/ip-addresses/` using a JSON file to parse it returns with the following error: `[{u'role': [u'"" is not a valid choice.']}]` When doing just a normal API call this is allowed/bypassed by filling in the role value as null. I need to keep the role value when parsing due to some rows not being empty. I have tried to fill the NaN rows with "null" but it returns the same error as above
adam closed this issue 2025-12-29 17:19:40 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jul 13, 2018):

Please post the exact API request you are making.

@jeremystretch commented on GitHub (Jul 13, 2018): Please post the exact API request you are making.
Author
Owner

@JSystem1 commented on GitHub (Jul 13, 2018):

Well I am doing the API posting from a JSON file requests.post(url,data = contents,headers=head, verify=False) where contents is contents = open('json/ipaddress.json', 'rb').read() So the problem is when doing a curl or through Swagger UI it works when leaving role as null or empty. The API request works when I would let say set the role: 40 (VIP) it would post successfully

Edit:
Just to add to this I have been using the same method of API posting for the creation of prefixes,Vlans,roles. Where role held null value sometimes also so it seems to be specifically with that endpoint

@JSystem1 commented on GitHub (Jul 13, 2018): Well I am doing the API posting from a JSON file `requests.post(url,data = contents,headers=head, verify=False)` where contents is `contents = open('json/ipaddress.json', 'rb').read()` So the problem is when doing a curl or through Swagger UI it works when leaving role as null or empty. The API request works when I would let say set the role: 40 (VIP) it would post successfully Edit: Just to add to this I have been using the same method of API posting for the creation of prefixes,Vlans,roles. Where role held null value sometimes also so it seems to be specifically with that endpoint
Author
Owner

@jeremystretch commented on GitHub (Jul 17, 2018):

I'm not able to assist you unless you post the exact API request being made.

@jeremystretch commented on GitHub (Jul 17, 2018): I'm not able to assist you unless you post the exact API request being made.
Author
Owner

@JSystem1 commented on GitHub (Jul 20, 2018):

{"address":".....","description":".....","status":"1","role":""} - Since its not a string and its left empty when I am converting CSV -> JSON an empty string appears

@JSystem1 commented on GitHub (Jul 20, 2018): {"address":".....","description":".....","status":"1","role":""} - Since its not a string and its left empty when I am converting CSV -> JSON an empty string appears
Author
Owner

@jeremystretch commented on GitHub (Jul 20, 2018):

An empty string is different than null. Use the word null or simply omit the field.

@jeremystretch commented on GitHub (Jul 20, 2018): An empty string is different than `null`. Use the word `null` or simply omit the field.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1842