title: How to get JSON data in an Odoo controller using type='json'?
body: <p>A few days ago I did a similar question here: <a href="https://stackoverflow.com/questions/35913866/how-to-get-json-data-in-an-odoo-controller">How to get JSON data in an Odoo controller?</a></p>
  
  <p>But now, I need to create a controller which receives only JSON data. So, I am doing the request from a Python console, this way:</p>
  
  <pre><code>import requests
  import json
  
  url = 'http://localhost:8069/odoo/test'
  headers = {'Content-Type': 'application/json'}
  data = {
      'name': 'Jane',
      'email': 'jane.doe@gmail.com',
  }
  data_json = json.dumps(data)
  r = requests.post(url=url, data=data_json, headers=headers)
  </code></pre>
  
  <p>I have created a controller which listens to <a href="http://localhost:8069/odoo/test" rel="noreferrer">http://localhost:8069/odoo/test</a>, this way:</p>
  
  <pre><code>import openerp.http as http
  from openerp.http import Response
  import logging
  _logger = logging.getLogger(__name__)
  
  
  class WebFormController(http.Controller):
  
      @http.route('/odoo/test', type='json',
                  auth='public', methods=['POST'], website=True)
      def index(self, **args):
          _logger.info('CONNECTION SUCCESSFUL')
          _logger.info(args)
          name = args.get('name', False)
          email = args.get('email', False)
          _logger.info(name)
          _logger.info(email)
          if not name:
              Response.status = '400 Bad Request'
          return '{"response": "OK"}'
  </code></pre>
  
  <p>The problem is that I am receiving an empty JSON in the controller. I can read <em>CONNECTION SUCCESFUL</em> in the log, with no error, but when I show <code>args</code>, I get <code>{}</code>, and obviously due to that, <code>False</code> when writing <code>name</code> and <code>email</code>.</p>
  
  <p>If I pass the data as a Python dictionary or as a string, I get the following error:</p>
  
  <p><code>Invalid JSON data: 'name=Jane&amp;email=jane.doe%40gmail.com'</code> or
  <code>Invalid JSON data: "{'name': 'Jane', 'email': 'jane.doe@gmail.com'}"</code> respectively.</p>
  
  <p>If I modify <code>type='json'</code> and I write <code>type='http'</code> instead, I get the following error:</p>
  
  <p><code>Function declared as capable of handling request of type 'http' but called with a request of type 'json'</code>.</p>
  
  <p>I have read that may be this could be solved if the request is sent using the parameter <code>json</code> instead of <code>data</code>, this way:</p>
  
  <pre><code>r = requests.post(url=url, json=data_json, headers=headers)
  </code></pre>
  
  <p>Unfortunately, the server which is going to make the request has an old operating system which cannot update the <code>python-requests</code> package, so I cannot use <code>json</code> parameter since it did not exist at the version installed in that server.</p>
  
  <p>Please, can anyone help me? I need get JSON data in the controller, not a string neither Python dictionaries.</p>