AnsweredAssumed Answered

Create Scan report through API

Question asked by Maximiliano Lagos on Apr 11, 2019
Latest reply on Apr 15, 2019 by DMFezzaReed

I was trying to download a PDF report, with the results of a scheduled scan which runs every day.

 

I realized, by reading the documentation, that I need to create the report first, and then download it.

 

The steps that am following, according to documentation, are:

 

  1. First, I get the last daily scan, by sending some filters and get the scan ID required on next step:
    1. $ curl -u "user:pass" -H "content-type: text/xml" -X "POST" --data-binary @- "https://qualysapi.qg3.apps.qualys.com/qps/rest/3.0/search/was/wasscan" < file.xml

  2. Then
    1. $ curl -u "user:pass"text/xml" -X "POST" —-data-binary @- "https://qualysapi.qg3.apps.qualys.com/qps/rest/3.0/create/was/report" < params.xml
    2. ## This is params.xml content ##

      <?xml version="1.0" encoding="UTF-8"?>

      <ServiceRequest>

        <data>

          <Report>

            <name><![CDATA[Scan Report for Servers]]></name>

            <format>PDF</format>

            <template>

              <id>103725</id>

            </template>

            <config>

              <scanReport>

                <target>

                  <scans>

                    <WasScan>

                      <id>2362741</id>

                    </WasScan>

                  </scans>

                </target>

              </scanReport>

            </config>

          </Report>

        </data>

      </ServiceRequest>


 

And, I am getting a weird error at that point (step 2). First, it says that --data-binary could not be resolved as host, so it seems like curl does not recognize the tag. Here is the complete log:

$ curl -u "user:pass" -H "content-type:text/xml" -X "POST" —-data-binary @- "https://qualysapi.qg3.apps.qualys.com/qps/rest/3.0/create/was/report" < params.xml

curl: (6) Could not resolve host: —-data-binary

curl: (6) Could not resolve host: -

<?xml version="1.0" encoding="UTF-8"?>

<ServiceResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://qualysapi.qg3.apps.qualys.com/qps/xsd/3.0/was/report.xsd">

  <responseCode>INVALID_REQUEST</responseCode>

  <responseErrorDetails>

    <errorMessage>name: Element is required.</errorMessage>

  </responseErrorDetails>

</ServiceResponse>

 

The error about the element required is, in my opinion, caused by the first block. 

Outcomes