You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Receive HTTP 200 from the web-server.
Device with name "teststuff" should be created and mounted to its rack position
Observed Behavior
Netbox:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/rest_framework/viewsets.py", line 114, in view
return self.dispatch(request, *args, **kwargs)
File "/opt/netbox/netbox/utilities/api.py", line 330, in dispatch
return super().dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/rest_framework/views.py", line 505, in dispatch
response = self.handle_exception(exc)
File "/usr/local/lib/python3.7/site-packages/rest_framework/views.py", line 465, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/lib/python3.7/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
raise exc
File "/usr/local/lib/python3.7/site-packages/rest_framework/views.py", line 502, in dispatch
response = handler(request, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/rest_framework/mixins.py", line 18, in create
serializer.is_valid(raise_exception=True)
File "/usr/local/lib/python3.7/site-packages/rest_framework/serializers.py", line 234, in is_valid
self._validated_data = self.run_validation(self.initial_data)
File "/usr/local/lib/python3.7/site-packages/rest_framework/serializers.py", line 436, in run_validation
value = self.validate(value)
File "/opt/netbox/netbox/dcim/api/serializers.py", line 398, in validate
validator.set_context(self)
Exception Type: AttributeError at /api/dcim/devices/ Exception Value: 'UniqueTogetherValidator' object has no attribute 'set_context'
{ "face": [ "Value must be passed directly (e.g. \"foo\": 123); do not use a dictionary or list." ] }
The text was updated successfully, but these errors were encountered:
2muchgit
changed the title
Unable to create Racked Device through REST API when defining Object "face"
Unable to create Racked Device through REST API when defining Variable "face"
Apr 21, 2020
Environment
Steps to Reproduce
curl -X POST -H "Content-Type: application/json" -H "Authorization: Token <TOKEN>" -H "Accept: application/json; indent=4" http://netbox.test/api/dcim/devices/ --data '{ "name": "teststuff", "display_name": "teststuff", "device_type": { "id": 43 }, "device_role": { "id": 2 }, "site": { "id": 27 }, "rack": { "id": 300 }, "position": 1, "face": 0, "status": 1 }'
Expected Behavior
Receive HTTP 200 from the web-server.
Device with name "teststuff" should be created and mounted to its rack position
Observed Behavior
Netbox:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/rest_framework/viewsets.py", line 114, in view
return self.dispatch(request, *args, **kwargs)
File "/opt/netbox/netbox/utilities/api.py", line 330, in dispatch
return super().dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/rest_framework/views.py", line 505, in dispatch
response = self.handle_exception(exc)
File "/usr/local/lib/python3.7/site-packages/rest_framework/views.py", line 465, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/lib/python3.7/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
raise exc
File "/usr/local/lib/python3.7/site-packages/rest_framework/views.py", line 502, in dispatch
response = handler(request, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/rest_framework/mixins.py", line 18, in create
serializer.is_valid(raise_exception=True)
File "/usr/local/lib/python3.7/site-packages/rest_framework/serializers.py", line 234, in is_valid
self._validated_data = self.run_validation(self.initial_data)
File "/usr/local/lib/python3.7/site-packages/rest_framework/serializers.py", line 436, in run_validation
value = self.validate(value)
File "/opt/netbox/netbox/dcim/api/serializers.py", line 398, in validate
validator.set_context(self)
Exception Type: AttributeError at /api/dcim/devices/ Exception Value: 'UniqueTogetherValidator' object has no attribute 'set_context'
Web-server:
[21/Apr/2020:10:12:15 +0000] "POST /api/dcim/devices/ HTTP/1.0" 500 22793 "-" "curl/7.58.0"
Notes
When sending the request, "face" seems to be the only argument whose value is not being accepted:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Token <TOKEN>" -H "Accept: application/json; indent=4" http://netbox.test/api/dcim/devices/ --data '{ "name": "teststuff", "display_name": "teststuff", "device_type": { "id": 43 }, "device_role": { "id": 2 }, "site": { "id": 27 }, "rack": { "id": 300 }, "position": 1, "face": "front", "status": 1 }'
Using "front" or "rear" Returns the same error as previously shown.
Any other value for "face" returns a proper response:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Token <TOKEN>" -H "Accept: application/json; indent=4" http://netbox.test/api/dcim/devices/ --data '{ "name": "teststuff", "display_name": "teststuff", "device_type": { "id": 43 }, "device_role": { "id": 2 }, "site": { "id": 27 }, "rack": { "id": 300 }, "position": "2", "face":"bla", "status": 1 }'
{ "face": [ "bla is not a valid choice." ] }
curl -X POST -H "Content-Type: application/json" -H "Authorization: Token <TOKEN>" -H "Accept: application/json; indent=4" http://netbox.test/api/dcim/devices/ --data '{ "name": "teststuff", "display_name": "teststuff", "device_type": { "id": 43 }, "device_role": { "id": 2 }, "site": { "id": 27 }, "rack": { "id": 300 }, "position": "2", "face":"", "status": 1 }'
{ "face": [ "Must specify rack face when defining rack position." ] }
curl -X POST -H "Content-Type: application/json" -H "Authorization: Token <TOKEN>" -H "Accept: application/json; indent=4" http://netbox.test/api/dcim/devices/ --data '{ "name": "teststuff", "display_name": "teststuff", "device_type": { "id": 43 }, "device_role": { "id": 2 }, "site": { "id": 27 }, "rack": { "id": 300 }, "position": "2", "face":{"id": 0}, "status": 1 }'
{ "face": [ "Value must be passed directly (e.g. \"foo\": 123); do not use a dictionary or list." ] }
The text was updated successfully, but these errors were encountered: