Closed agowa closed 4 years ago
Can you actually propose a specific change? We aren't going to read through an RFC to extract examples.
There are examples in the rfc section 3: https://tools.ietf.org/html/rfc7807#section-3
HTTP/1.1 400 Bad Request
Content-Type: application/problem+json
Content-Language: en
{
"type": "https://example.net/validation-error",
"title": "Your request parameters didn't validate.",
"invalid_params": [ {
"name": "age",
"reason": "must be a positive integer"
},
{
"name": "color",
"reason": "must be 'green', 'red' or 'blue'"}
]
}
The validation errors are primarily a function of the Django REST Framework. This might be worth proposing to that project, but it's not something we can commit development resources to in NetBox.
From the DRF issue:
It would be more correct to say it is something they don't want to fix. You can change the default error representation by overriding the default error handler. (...) We probably could add another error handler that would implement that RFC though and some 3rd party may already implement it
Such a 3rd party library is drf-problems. https://shivanshs9.me/medium/drf-problems-21f7bb4d4675 https://pypi.org/project/drf-problems/
Environment
Proposed Functionality
Please add machine readable error messages, for example like defined by RFC7807
Use Case
Given the following API call
the API currently returns this in case of an error:
This error message is hard to handle. It would be much easier if the API follows any standard like e.g. RFC7807.
(To reproduce the above error one just needs a 2nd VM that has the primary IP already assigned before one tries to assign it to another one).
Database Changes
none
External Dependencies
none