Open abdulwahid24 opened 10 years ago
This is an issue with the header format sent with your request. I don't know of the top of my head why it is text/plain but it should be application/json.
Hello,
Same problem here.
Request URL /backend/api/v1/user/login/?username=seraf&password=XXXXXX&api_key=special-key
Response Body
{
"error_message": "The format indicated '' had no available deserialization method. Please check your formats
and content_types
on your Serializer.",
"traceback": "Traceback (most recent call last):\n\n File \"/usr/local/lib/python2.7/dist-packages/tastypie/resources.py\", line 201, in wrapper\n response = callback(request, _args, _kwargs)\n\n File \"/home/julien/Sandbox/LISA/lisa/server/web/weblisa/api/accounts.py\", line 124, in dispatch_login\n return self.dispatch_public('login', request, _kwargs)\n\n File \"/home/julien/Sandbox/LISA/lisa/server/web/weblisa/api/mixins.py\", line 35, in dispatch_public\n response = method(request, *_kwargs)\n\n File \"/home/julien/Sandbox/LISA/lisa/server/web/weblisa/api/accounts.py\", line 127, in post_login\n data = self.deserialize(request, request.body, format=request.META.get('CONTENT_TYPE', 'application/json'))\n\n File \"/usr/local/lib/python2.7/dist-packages/tastypie/resources.py\", line 381, in deserialize\n deserialized = self._meta.serializer.deserialize(data, format=request.META.get('CONTENT_TYPE', 'application/json'))\n\n File \"/usr/local/lib/python2.7/dist-packages/tastypie/serializers.py\", line 221, in deserialize\n raise UnsupportedFormat(\"The format indicated '%s' had no available deserialization method. Please check your formats
and content_types
on your Serializer.\" % format)\n\nUnsupportedFormat: The format indicated '' had no available deserialization method. Please check your formats
and content_types
on your Serializer.\n"
}
But, using POSTMAN application and sending the parameters using the application/json, it works. I suspect a bug with swagger (as the api works correctly on tastypie side).
I tried to print request.META.get('CONTENT_TYPE'). With postman I got "application/json", with swagger UI, got nothing. Hope it will help.
Hi, I think I found the problem. The post parameters are sent in the query and not the body. In the 1.2 specs, there's a paramType : https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#524-parameter-object I tried to set 'paramType': 'body' in my field but with no effect (with the last master). Maybe not implemented ?
Probably related to the swagger specs not being fully implemented. See here for a starting point.
i also got same error
my content type is application/json still it not working
help me
same issue with angularjs.
I have added custom api using extra_action such as class Meta: extra_actions = [ { 'name': 'login', 'http_method': 'POST', 'resource_type':'list', 'fields':{ 'username': { 'type': 'string', 'required': True, 'description':'Unique username required.' }, 'password': { 'type': 'string', 'required': True, 'description':'password required' } } } ]
This display the api in doc as mentioned in attached picture.
But when i fill all mentioned fields and press "Try it Out" than it gives me error such as
{ "error_message": "The format indicated 'text/plain' had no available deserialization method. Please check your
formats
andcontent_types
on your Serializer.", "traceback": "Traceback (most recent call last):\n\n File \"/home/synerzip/educator-env/local/lib/python2.7/site-packages/tastypie/resources.py\", line 195, in wrapper\n response = callback(request, _args, *_kwargs)\n\n File \"/home/synerzip/Dropbox/Educator/educator-backend/educator/users/api.py\", line 121, in login\n data = self.deserialize(request, request.body, format=request.META.get('CONTENT_TYPE', 'application/json'))\n\n File \"/home/synerzip/educator-env/local/lib/python2.7/site-packages/tastypie/resources.py\", line 375, in deserialize\n deserialized = self._meta.serializer.deserialize(data, format=request.META.get('CONTENT_TYPE', 'application/json'))\n\n File \"/home/synerzip/educator-env/local/lib/python2.7/site-packages/tastypie/serializers.py\", line 219, in deserialize\n raise UnsupportedFormat(\"The format indicated '%s' had no available deserialization method. Please check yourformats
andcontent_types
on your Serializer.\" % format)\n\nUnsupportedFormat: The format indicated 'text/plain' had no available deserialization method. Please check yourformats
andcontent_types
on your Serializer.\n" }Please refer the attached image.
Thanks, AbdulWahid