Skip to content

500 error on sib-form POST : KeyError at /api/action-groups/ 'pk'

JSON :

{
  "@context": "http://owl.openinitiative.com/oicontext.jsonld",
  "@graph": [
    {
      "@id": "./",
      "http://happy-dev.fr/owl/#dates": "2019-03-13",
      "http://happy-dev.fr/owl/#description": "Debug sib-form",
      "http://happy-dev.fr/owl/#frequency": "Debug sib-form",
      "http://happy-dev.fr/owl/#kind": "Debug sib-form",
      "http://happy-dev.fr/owl/#loomios": "https://drive.google.com/drive/folders/1KcfRuWDA4z1oYa1ApsKkZ5QBg4L6KiOG",
      "http://happy-dev.fr/owl/#objective": "Debug sib-form",
      "http://happy-dev.fr/owl/#place": "Debug sib-form",
      "http://happy-dev.fr/owl/#representatives": {
        "@id": "http://127.0.0.1:8000/api/representatives/4/"
      },
      "http://happy-dev.fr/owl/#title-informations": "Informations du groupe (2/3)",
      "http://happy-dev.fr/owl/#title-modules": "Modules de support (3/3)",
      "http://happy-dev.fr/owl/#title-objectives": "Définition de l'objectif (1/3)",
      "http://www.w3.org/2000/01/rdf-schema#label": "Debug sib-form"
    }
  ]
}

ERROR LOG :

KeyError at /api/action-groups/
'pk'

Request Method: POST
Request URL: http://127.0.0.1:8000/api/action-groups/
Django Version: 1.11.20
Python Executable: /var/www/united4earth/venv/bin/python3
Python Version: 3.6.7
Python Path: ['/var/www/united4earth', '/var/www/djangoldp', '/var/www', '/var/www/html', '/var/www/united4earth', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/var/www/united4earth/venv/lib/python3.6/site-packages']
Server time: mar, 12 Mar 2019 20:15:04 +0100
Installed Applications:
['data_manager',
 'djangoldp',
 'djangoldp_conversation',
 'guardian',
 'registration',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']


Traceback:  

File "/var/www/djangoldp/djangoldp/serializers.py" in to_internal_value
  106.             return super().to_internal_value(data[self.parent.url_field_name])
  
    
      During handling of the above exception (string indices must be integers), another exception occurred:
    
  

File "/var/www/united4earth/venv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/var/www/united4earth/venv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/var/www/united4earth/venv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/var/www/united4earth/venv/lib/python3.6/site-packages/django/views/decorators/csrf.py" in wrapped_view
  58.         return view_func(*args, **kwargs)

File "/var/www/united4earth/venv/lib/python3.6/site-packages/rest_framework/viewsets.py" in view
  116.             return self.dispatch(request, *args, **kwargs)

File "/var/www/djangoldp/djangoldp/views.py" in dispatch
  135.         response = super(LDPViewSet, self).dispatch(request, *args, **kwargs)

File "/var/www/united4earth/venv/lib/python3.6/site-packages/rest_framework/views.py" in dispatch
  495.             response = self.handle_exception(exc)

File "/var/www/united4earth/venv/lib/python3.6/site-packages/rest_framework/views.py" in handle_exception
  455.             self.raise_uncaught_exception(exc)

File "/var/www/united4earth/venv/lib/python3.6/site-packages/rest_framework/views.py" in dispatch
  492.             response = handler(request, *args, **kwargs)

File "/var/www/united4earth/venv/lib/python3.6/site-packages/rest_framework/mixins.py" in create
  20.         serializer.is_valid(raise_exception=True)

File "/var/www/united4earth/venv/lib/python3.6/site-packages/rest_framework/serializers.py" in is_valid
  236.                 self._validated_data = self.run_validation(self.initial_data)

File "/var/www/united4earth/venv/lib/python3.6/site-packages/rest_framework/serializers.py" in run_validation
  434.         value = self.to_internal_value(data)

File "/var/www/united4earth/venv/lib/python3.6/site-packages/rest_framework/serializers.py" in to_internal_value
  491.                 validated_value = field.run_validation(primitive_value)

File "/var/www/united4earth/venv/lib/python3.6/site-packages/rest_framework/serializers.py" in run_validation
  626.         value = self.to_internal_value(data)

File "/var/www/djangoldp/djangoldp/serializers.py" in to_internal_value
  108.             return super().to_internal_value(data)

File "/var/www/djangoldp/djangoldp/serializers.py" in to_internal_value
  35.         return [self.child.to_internal_value(item) for item in data]

File "/var/www/djangoldp/djangoldp/serializers.py" in <listcomp>
  35.         return [self.child.to_internal_value(item) for item in data]

File "/var/www/djangoldp/djangoldp/serializers.py" in to_internal_value
  302.                         ret['pk'] = match.kwargs['pk']

Exception Type: KeyError at /api/action-groups/
Exception Value: 'pk'
Edited by Ghost User