-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
NetBox version
v3.3.9
Python version
3.9
Steps to Reproduce
Create a custom field object and multiobject (here: for dcim.device)
Edit a device and fill the new custom fields via UI.
Try unsetting the custom fields via REST API, for example:
curl -X 'PATCH'
'http://localhost:8000/api/dcim/devices/1/'
-H 'accept: application/json'
-H 'Content-Type: application/json'
-H 'Authorization: Token token'
-d '{
"custom_fields": {
"object_field": null
}
}'
and
curl -X 'PATCH'
'http://localhost:8000/api/dcim/devices/1/'
-H 'accept: application/json'
-H 'Content-Type: application/json'
-H 'Authorization: Token token'
-d '{
"custom_fields": {
"multiobject_field": null
}
}'
Also, try updating the object with the full payload received when querying the API:
curl -X 'PATCH'
'http://localhost:8000/api/dcim/devices/1/'
-H 'accept: application/json'
-H 'Content-Type: application/json'
-H 'Authorization: Token token'
-d '{
"custom_fields": {
"object_field": {"id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "display": "testdevice", "name": "testdevice"}
}
}'
curl -X 'PATCH'
'http://localhost:8000/api/dcim/devices/1/'
-H 'accept: application/json'
-H 'Content-Type: application/json'
-H 'Authorization: Token token'
-d '{
"custom_fields": {
"multiobject_field": [{"id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "display": "testdevice", "name": "testdevice"}]
}
}'
Expected Behavior
The custom fields of the object should be cleared in the first example, and updated in the second.
Observed Behavior
The examples yield variations of an "Unknown related object" error message.
Unsetting custom fields:
{"custom_fields":["Unknown related object(s): None"]}
Updating custom field object as received from the API:
{"custom_fields":["Unknown related object(s): {'id': 1, 'url': 'http://localhost:8000/api/dcim/devices/1/', 'display': 'testdevice', 'name': 'testdevice'}"]}
Updating custom field multiobject as received from the API:
{"custom_fields":["Unknown related object(s): [{'id': 1, 'url': 'http://localhost:8000/api/dcim/devices/1/', 'display': 'testdevice', 'name': 'testdevice'}]"]}