title: How to escape special characters for data payload while using requests.request()?
body: <p>I have a REST API and I am making a POST request using the code below:</p>
  <pre class="lang-py prettyprint-override"><code>hdrs = {'Client-Scope': scope,'OAuth-Client-Info': 'Basic '+authcode, 'Authorization': 'Bearer '+access_token}
  requests.request(&quot;POST&quot;,&quot;some URL here&quot;, headers=hdrs, data= {'data':template})
  </code></pre>
  <p>Here is the <code>template</code>:</p>
  <pre class="lang-py prettyprint-override"><code>template = '{&quot;product_id&quot;,&quot;text&quot;:&quot;some logs here&quot;}'
  </code></pre>
  <p>This is working fine if the template just has &quot;plain&quot; text:</p>
  <pre class="lang-json prettyprint-override"><code>&quot;text&quot;:&quot;some plain text&quot;
  </code></pre>
  <p>But when I have text with special characters:</p>
  <pre class="lang-json prettyprint-override"><code>&quot;text&quot;:&quot;someone's text is &quot;not plain&quot;. it is \'random\' with special chars \^ so on...&quot;
  </code></pre>
  <p>The request is failing with the error:</p>
  <pre class="lang-none prettyprint-override"><code>Error at line 2, col 391: Invalid escape sequence \\'
  </code></pre>
  <p>This is actually a code for uploading some logs available in the form of files to a database. I cannot format it but upload the log as it is.</p>