title: Tastypie with application/x-www-form-urlencoded
body: <p>I'm having a bit of difficulty figuring out what my next steps should be. I am using tastypie to create an API for my web application. </p>
  
  <p>From another application, specifically ifbyphone.com, I am receiving a POST with no headers that looks something like this: </p>
  
  <pre><code>post data:http://myapp.com/api/
  callerid=1&amp;someid=2&amp;number=3&amp;result=Answered&amp;phoneid=4
  </code></pre>
  
  <p>Now, I see in my server logs that this is hitting my server.But tastypie is complaining about the format of the POST.</p>
  
  <blockquote>
    <p>{"error_message": "The format indicated
    'application/x-www-form-urlencoded' had no available deserialization
    method. Please check your <code>formats</code> and <code>content_types</code> on your
    Serializer.", "traceback": "Traceback (most recent call last):\n\n 
    File \"/usr/local/lib/python2.7/dist-packages/tastypie/resources.py\"</p>
  </blockquote>
  
  <p>I also receive the same message when I try to POST raw data using curl, which I "believe" is the same basic process being used by ifbyphone's POST method: </p>
  
  <pre><code>curl -X POST --data 'callerid=1&amp;someid=2&amp;number=3&amp;duration=4&amp;phoneid=5' http://myapp.com/api/
  </code></pre>
  
  <p>So, assuming my problem is actually what is specified in the error message, and there is no deserialization method, how would I go about writing one? </p>
  
  <h3>#### Update ######</h3>
  
  <p>With some help from this commit ( <a href="https://github.com/toastdriven/django-tastypie/commit/7c5ea699ff6a5e8ba0788f23446fa3ac31f1b8bf" rel="noreferrer">https://github.com/toastdriven/django-tastypie/commit/7c5ea699ff6a5e8ba0788f23446fa3ac31f1b8bf</a> ) I've been playing around with writing my own serializer, copying the basic framework from the documentation ( <a href="https://django-tastypie.readthedocs.org/en/latest/serialization.html#implementing-your-own-serializer" rel="noreferrer">https://django-tastypie.readthedocs.org/en/latest/serialization.html#implementing-your-own-serializer</a> )</p>
  
  <pre><code>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)&gt;1 else v[0] )
              for k, v in urlparse.parse_qs(data).iteritems())
          return qs
  
      def to_urlencode(self,content): 
          pass
  </code></pre>