title: Convert string to json in order to pass in requests.post
body: <p>I have 2 strings which are stored in variables</p>
  
  <pre><code>headers = str('{"Authorization":"'+auth+'"}')
  otp = str('{"otp":"'+otp+'"}')
  </code></pre>
  
  <p>Using ast library I convert them to dictionary.</p>
  
  <pre><code>data = ast.literal_eval(otp)
  head = ast.literal_eval(headers)
  
  Output : 
  
  {'otp': '0910'}
  {'Authorization': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIU'}
  </code></pre>
  
  <p>But when I pass them to:</p>
  
  <pre><code>response = requests.post(url, params=data, headers = head)
  </code></pre>
  
  <p>I get this message</p>
  
  <pre><code>{'status': 'failure', 'message': 'invalid json'}
  </code></pre>
  
  <p>I understand this is a problem of single and double quotes but I am bit confused how to change single quotes to double quotes.</p>
  
  <p>I tried using <strong>json.dumps()</strong> but this returns string which is not acceptable.</p>
  
  <p>Please help.</p>