-
Notifications
You must be signed in to change notification settings - Fork 41
Closed
Labels
1 - RequestA request made by a member of the communityA request made by a member of the community2 - APIIssues that are related to the APIsIssues that are related to the APIsgood first issue
Description
From a user support email:
I believe the 500 error he gets is because he is sending the requests body as JSON rather than form data.
I get confused by that all the time too.
Can we either give a proper error message for cases like this, or make [all] APIs accept JSON payload (like all modern APIs)?
I believe you mentioned earlier that it is harder to get JSON payload that form data payload, but can you just write a utility function for that and use it in API request handlers?
Currently, some endpoins accept JSON, and some form data
User email:
Now I’m getting a 500 server error that I will attempt to troubleshoot.
From the logs I can gather that the POST request may be malformed as it doesn’t appear to pick up on the target id:
[Thu Aug 18 07:15:38.085715 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] Traceback (most recent call last): [Thu Aug 18 07:15:38.085717 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] File "/home/specify/currentversion/specify7/ve/lib64/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner [Thu Aug 18 07:15:38.085719 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] response = get_response(request) [Thu Aug 18 07:15:38.085721 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] File "/home/specify/currentversion/specify7/ve/lib64/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response [Thu Aug 18 07:15:38.085723 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] response = self.process_exception_by_middleware(e, request) [Thu Aug 18 07:15:38.085726 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] File "/home/specify/currentversion/specify7/ve/lib64/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response [Thu Aug 18 07:15:38.085728 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] response = wrapped_callback(request, *callback_args, **callback_kwargs) [Thu Aug 18 07:15:38.085730 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] File "/home/specify/currentversion/specify7/specifyweb/specify/views.py", line 20, in wrapped [Thu Aug 18 07:15:38.085732 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] return view(request, *args, **kwargs) [Thu Aug 18 07:15:38.085735 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] File "/home/specify/currentversion/specify7/ve/lib64/python3.6/site-packages/django/views/decorators/http.py", line 40, in inner [Thu Aug 18 07:15:38.085737 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] return func(request, *args, **kwargs) [Thu Aug 18 07:15:38.085739 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] File "/home/specify/currentversion/specify7/specifyweb/specify/views.py", line 32, in wrapped [Thu Aug 18 07:15:38.085755 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] return view(request, *args, **kwargs) [Thu Aug 18 07:15:38.085758 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] File "/usr/lib64/python3.6/contextlib.py", line 52, in inner [Thu Aug 18 07:15:38.085760 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] return func(*args, **kwds) [Thu Aug 18 07:15:38.085762 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] File "/home/specify/currentversion/specify7/specifyweb/specify/tree_views.py", line 30, in wrapper [Thu Aug 18 07:15:38.085764 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] mutation(*args, **kwargs) [Thu Aug 18 07:15:38.085766 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] File "/home/specify/currentversion/specify7/specifyweb/specify/tree_views.py", line 253, in merge [Thu Aug 18 07:15:38.085768 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] target = get_object_or_404(tree, id=request.POST['target']) [Thu Aug 18 07:15:38.085770 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] File "/home/specify/currentversion/specify7/ve/lib64/python3.6/site-packages/django/utils/datastructures.py", line 80, in __getitem__ [Thu Aug 18 07:15:38.085772 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] raise MultiValueDictKeyError(key) [Thu Aug 18 07:15:38.085776 2022] [wsgi:error] [pid 7547] [remote [10.175.116.29:64655](http://10.175.116.29:64655/)] django.utils.datastructures.MultiValueDictKeyError: 'target'
Metadata
Metadata
Assignees
Labels
1 - RequestA request made by a member of the communityA request made by a member of the community2 - APIIssues that are related to the APIsIssues that are related to the APIsgood first issue
Type
Projects
Status
✅ Done