AnsweredAssumed Answered

INVALID XML response for WAS 2.2 API scan call

Question asked by Q Nimbus on Mar 24, 2012
Latest reply on Apr 28, 2016 by Abraham Martin Norada

Issue

I am receiving an XML null error when calling a web application scan through Python code via urllib2.  The web application already exists.  The same call via curl with the same data works.  Why do urllib2 calls not work?

Data

XML data =

<ServiceRequest>
    <data>
        <WasScan>
            <name>Cheese API</name>
            <type>VULNERABILITY</type> 
            <target>
                <webApp>
                    <id>[redacted]</id>
                </webApp>
            </target>
            <profile>
                <id>[redacted]</id>
            </profile>
        </WasScan>
    </data>
</ServiceRequest>

 

Curl call

 

curl -u "[redacted]:[redacted]" -H "content-type: text/xml" -X "POST" -d @- "https://qualysapi.qualys.com/qps/rest/3.0/launch/was/wasscan" < data.xml

 

Note: data.xml contains the above XML data.

 

curl response:

<?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/3.0/was/wasscan.xsd">
  <responseCode>SUCCESS</responseCode>
  <count>1</count>
  <data>
    <WasScan>
      <id>[redacted]</id>
    </WasScan>
  </data>
</ServiceResponse>

 

I confirmed in the GUI that the scan initiated successfully via curl.

Python urllib2 call

request headers =

{'Content-type': 'text/xml', 'Authorization': 'Basic [redacted]'}

 

request url =

'https://qualysapi.qualys.com/qps/rest/3.0/launch/was/webscan'

 

request method =

'POST'

 

Note: POST data contains the XML data above.

 

response =

<ServiceResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://qualysapi.qualys.com/qps/xsd/3.0/was/webscan.xsd">
  <responseCode>INVALID_XML</responseCode>
  <responseErrorDetails>
    <errorMessage>Invalid XML format: null</errorMessage>
  </responseErrorDetails>
</ServiceResponse>

 

Second try, remove whitespace

Removed all whitespace from xml.data in case the newlines were the issue.

XML data =

<ServiceRequest><data><WasScan><name>CheeseAPI</name><type>VULNERABILITY</type><target><webApp><id>[redacted]</id></webApp></target><profile><id>[redacted]</id></profile></WasScan></data></ServiceRequest>

 

response (same) =

<ServiceResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://qualysapi.qualys.com/qps/xsd/3.0/was/webscan.xsd">
  <responseCode>INVALID_XML</responseCode>
  <responseErrorDetails>
    <errorMessage>Invalid XML format: null</errorMessage>
  </responseErrorDetails>
</ServiceResponse>

Outcomes