title: Python - ï»¿ in front of an api response
body: <p>The response the API is giving me looks like this:</p>
  <p>I am using FastAPI to send a post request to an API that returns an XML string:</p>
  <pre class="lang-py prettyprint-override"><code>import requests
  from fastapi import APIRouter, Response
  
  router = APIRouter()
  
  def __post():
      headers = {'Content-Type': 'application/xml'}
      auth = requests.auth.HTTPBasicAuth(&quot;username&quot;, &quot;password&quot;)
    
      response = requests.post('https://example.org/id', headers=headers, auth=auth)
      return response.text
  
  @router.get(&quot;/{id}&quot;)
  def test():
      xml = __post()
      return Response(content=xml, media_type=&quot;application/xml&quot;)
  
  The response from here is:
  
  ```xml
  &quot;ï»¿&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;utf-8\&quot;?&gt;\r\n
  ...
  </code></pre>
  <p>As you can see, the characters <code>ï»¿</code> is added in front. I looked it up, and I can see it's something to do with encoding (<code>utf-8-sig</code>). I even tried to save the response to an xml file on the server:</p>
  <pre class="lang-py prettyprint-override"><code># Write response to file
  with open('response.xml', 'w', encoding='utf-8-sig') as f:
       f.write(xml)
  </code></pre>
  <p>But the characters <code>ï»¿</code> is still added.</p>
  <p>How can I parse the XML response withouth the characters <code>ï»¿</code>?</p>