AnsweredAssumed Answered

QualysAPI - List Cloud Agents call via Python - API version issue

Question asked by smita patankar on May 8, 2020

qualys api Qualys Community Qualys Cloud Platform 

 

 

This is the working curl call:

curl -u xx:yy -X "POST" -H "X-Requested-With: curl" -H "Content-Type: text/xml" --data-binary @file.xml "https://qualysapi.qualys.com/qps/rest/2.0/search/am/hostasset/"

file.xml contains:

<ServiceRequest>
<preferences>
<limitResults>2</limitResults>
</preferences>
<filters>
<Criteria field="trackingMethod" operator="EQUALS">QAGENT</Criteria>
<Criteria field = "id" operator = "GREATER">0</Criteria>
</filters>
</ServiceRequest>

I am trying to execute same call via python qualysapi module, but getting error related to api version. What am I missing? I tried sending api_version="2", its giving similar error.

 

 

from qualysapi import connect
conn = connect(username="xx", password="yy", hostname="qualysapi.qualys.com")
api = "/qps/rest/2.0/search/am/hostasset"
parm = '''<ServiceRequest><preferences><limitResults>2</limitResults></preferences><filters><Criteria field="trackingMethod" operator="EQUALS">QAGENT</Criteria><Criteria field = "id" operator = "GREATER">0</Criteria></filters></ServiceRequest>'''
result = conn.request(api,parm)
print(result)

 

 

?xml version="1.0" encoding="UTF-8"?>
<ServiceResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://qualysapi.qualys.com/qps/xsd/1.0/rest/2.0.xsd">
<responseCode>INVALID_API_VERSION</responseCode>
<responseErrorDetails>
<errorMessage>The API version v1.0 specified does not support objects of type 2.0.</errorMessage>
<errorResolution>Verify the versions supported for this API.</errorResolution>
</responseErrorDetails>
</ServiceResponse>

Outcomes