title: Qualys API Integration with Python
body: <p>Having spent the past few days trying to get the Qualys API to work with python, I am usually running into errors such as 401 and errors of that sort, due to the fact that python code examples say they are unsupported.</p>
  <p>Since Qualys API is written with curl, I used <a href="https://curl.trillworks.com/#" rel="nofollow noreferrer">Curl.trillworks.com</a> to convert curl to python.</p>
  <p>The code I used was: (curl)</p>
  <pre><code>curl -u &quot;USERNAME:PASSWD&quot; -H &quot;X-Requested-With: Curl&quot; -X &quot;POST&quot; -d
  &quot;action=create&amp;title=My+Dynamic+Search+List&amp;global=1&amp;published_dat
  e_within_last_days=7&amp;patch_available=1&quot;
  &quot;https://qualysapi.qualys.com/api/2.0/fo/qid/search_list/dynamic/&quot;
  </code></pre>
  <p>and converted it into python:</p>
  <pre><code>import requests
  
  headers = {
      'X-Requested-With': 'Curl',
  }
  
  data = [
    ('published_date_within_last_days', '7'),
    ('patch_available', '1'),
  ]
  
  response = requests.post('https://qualysapi.qualys.com/api/2.0/fo/qid/search_list/dynamic/', headers=headers, data=data, auth=('USRNAME', 'PASSWORD'))
  print (response)
  </code></pre>
  <p>And got a 401 response. Any ideas or any more clarifications I should add? Thanks</p>
  <p><strong>UPDATE - 12/27/2020</strong></p>
  <p>Its been a while since I had this problem. Not sure what the issue was but for anyone else having the same issue, I would recommend plugging in the CURL statements into tools like Insomnia or Postman which convert these into any language. That would help you get more accurate conversions.</p>