The query in the form-data via postman, in the DRF falls?

Test API with Postman, all requests the server receives fine, except for form-data.
# coding: utf8
import logging
from django.views.decorators.csrf import csrf_exempt
from rest_framework.decorators import api_view, parser_classes
from rest_framework.parsers import JSONParser, FormParser, MultiPartParser
from rest_framework.response import Response
from api.models import UserProfile
from api.utils.query_obj import QuerySetObj
from api.controllers.telegram import TelegramInternal

logger = logging.getLogger(__name__)


@api_view(['POST'])
@parser_classes((JSONParser, FormParser, MultiPartParser))
@csrf_exempt
def telegram_community_add(request):
"'
 content-type: form-data
"'

 if request.method != 'POST':
 return Response(dict(error=dict(code=1, description='Incorrect request format')))
else:
 data = request.data
 token = data.get('token')
 user_obj = QuerySetObj('UserProfile', token).get()
 if user_obj is False:
 return Response(dict(error=dict(code=3, description='Invalid user token')))
else:
 # import pdb; pdb.set_trace()
 if 'community_id' and 'bot_token' in data:
 community_id = data.get('community_id')
 bot_token = data.get('bot_token')
 community_id_created = TelegramInternal().community_save(community_id, bot_token, user_obj)
 return Response(dict(response=dict(community_id=community_id_created)))
else:
 return Response(dict(error=dict(code=2, description='Required parameter missed')))


logs...
web_1 | Internal Server Error: /api/v1/communities/tl/add
web_1 | Traceback (most recent call last):
web_1 | File "/usr/local/lib/python3.4/site-packages/django/core/handlers/exception.py", line 42, in inner
web_1 | response = get_response(request)
web_1 | File "/usr/local/lib/python3.4/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
web_1 | response = self._get_response(request)
web_1 | File "/usr/local/lib/python3.4/site-packages/django/core/handlers/base.py", line 187, in _get_response
web_1 | response = self.process_exception_by_middleware(e, request)
web_1 | File "/usr/local/lib/python3.4/site-packages/django/core/handlers/base.py", line 185, in _get_response
web_1 | response = wrapped_callback(request, *callback_args, **callback_kwargs)
web_1 | File "/usr/local/lib/python3.4/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
web_1 | return view_func(*args, **kwargs)
web_1 | File "/usr/local/lib/python3.4/site-packages/django/views/generic/base.py", line 68, in view
web_1 | return self.dispatch(request, *args, **kwargs)
web_1 | File "/usr/local/lib/python3.4/site-packages/rest_framework/views.py", line 483, in dispatch
web_1 | response = self.handle_exception(exc)
web_1 | File "/usr/local/lib/python3.4/site-packages/rest_framework/views.py", line 443, in handle_exception
web_1 | self.raise_uncaught_exception(exc)
web_1 | File "/usr/local/lib/python3.4/site-packages/rest_framework/views.py", line 480, in dispatch
web_1 | response = handler(request, *args, **kwargs)
web_1 | File "/usr/local/lib/python3.4/site-packages/rest_framework/decorators.py", line 53, in handler
web_1 | return func(*args, **kwargs)
web_1 | File "/usr/local/lib/python3.4/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
web_1 | return view_func(*args, **kwargs)
web_1 | File "./api/versioned/v1/community/views.py", line 35, in telegram_community_add
web_1 | community_id_created = TelegramInternal().community_save(community_id, bot_token, user_obj)
web_1 | File "./api/controllers/telegram.py", line 136, in community_save
web_1 | community_info = TelegramBotApi(bot_token).get_chat(channel_link)
web_1 | File "./api/controllers/telegram.py", line 44, in get_chat
web_1 | req = requests.post(url, data=data)
web_1 | File "/usr/local/lib/python3.4/site-packages/requests/api.py", line 111, in post
web_1 | return request('post', url, data=data, json=json, **kwargs)
web_1 | File "/usr/local/lib/python3.4/site-packages/requests/api.py", line 57, in request
web_1 | return session.request(method=method, url=url, **kwargs)
web_1 | File "/usr/local/lib/python3.4/site-packages/requests/sessions.py", line 475, in request
web_1 | resp = self.send(prep, **send_kwargs)
web_1 | File "/usr/local/lib/python3.4/site-packages/requests/sessions.py", line 579, in send
web_1 | adapter = self.get_adapter(url=request.url)
web_1 | File "/usr/local/lib/python3.4/site-packages/requests/sessions.py", line 653, in get_adapter
web_1 | InvalidSchema raise("No connection adapters were found for '%s'" % url)
web_1 | requests.exceptions.InvalidSchema: No connection adapters were found for '605534238:AAEcdbnXqNt3t9npDi5Lg9mQQYPSW5CYqg0/getChat'
web_1 | [pid: 13|app: 0|req: 2/10] 172.18.0.1 () {36 vars in 586 bytes} [Mon Jul 23 11:28:30 2018] POST /api/v1/communities/tl/add => generated 15568 bytes in 229 msecs (HTTP/1.1 500) 3 headers in 107 bytes (3 switches on core 0)


Is under form-data need to write custom parser and out of the box comes? Or the problem is quite different?
June 3rd 19 at 18:54
0 answer

Find more questions by tags PythonDjango