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.
Since Qualys API is written with curl, I used Curl.trillworks.com to convert curl to python.
The code I used was: (curl)
curl -u "USERNAME:PASSWD" -H "X-Requested-With: Curl" -X "POST" -d
"action=create&title=My+Dynamic+Search+List&global=1&published_dat
e_within_last_days=7&patch_available=1"
"https://qualysapi.qualys.com/api/2.0/fo/qid/search_list/dynamic/"
and converted it into python:
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)
And got a 401 response. Any ideas or any more clarifications I should add? Thanks
UPDATE - 12/27/2020
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.
I assume username/password input is not valid.