It’s hard for me to understand what my next steps should be. I use tastypie to create an API for my web application.
From another application, in particular ifbyphone.com, I get POST without headers that look something like this:
post data:http://myapp.com/api/ callerid=1&someid=2&number=3&result=Answered&phoneid=4
Now I see in my server logs that this applies to my server. But tastypie complains about the POST format.
{"error_message": "The specified format" application / x-www-form-urlencoded "did not have a deserialization method. Check the formats and content_types on your Serializer.", "Traceback": "Traceback (last last call): \ n \ n File \ "/ usr / local / lib / python 2.7 / dist-packages / tastypie / resources.py \"
I also get the same message when I try to execute POST data using curl, which I consider "the same basic process used by the ifbyphone POST method:
curl -X POST --data 'callerid=1&someid=2&number=3&duration=4&phoneid=5' http://myapp.com/api/
So, if my problem is actually what is indicated in the error message and there is no deserialization method, how would I start writing?
#### Update ######
With some help from this commit ( https://github.com/toastdriven/django-tastypie/commit/7c5ea699ff6a5e8ba0788f23446fa3ac31f1b8bf ) I played with writing my own serializer by copying the basic structure from the documentation ( https://django-tastyp.s. en / latest / serialization.html # implementing-your-own-serializer )
import urlparse from tastypie.serializers import Serializer class urlencodeSerializer(Serializer): formats = ['json', 'jsonp', 'xml', 'yaml', 'html', 'plist', 'urlencode'] content_types = { 'json': 'application/json', 'jsonp': 'text/javascript', 'xml': 'application/xml', 'yaml': 'text/yaml', 'html': 'text/html', 'plist': 'application/x-plist', 'urlencode': 'application/x-www-form-urlencoded', } def from_urlencode(self, data,options=None): """ handles basic formencoded url posts """ qs = dict((k, v if len(v)>1 else v[0] ) for k, v in urlparse.parse_qs(data).iteritems()) return qs def to_urlencode(self,content): pass