Thursday, January 19, 2012

ReportDefinition XML Schema Definition is now available

Unlike reports in previous AdWords API versions, v201109 AdHoc reports are downloaded by POSTing XML to a URL rather than defining them using a SOAP service; therefore they have no WSDL document to describe the XML payload. To ensure that your ReportDefinition XML is valid when sending it to the API, we are now publishing an XML Schema Definition (XSD).

This XSD is tied to the versioned Report Download endpoint, allowing us to make incremental changes to reporting as needed. Here’s an example URL used to obtain the XSD for v201109 ReportDefinitions:

https://adwords.google.com/api/adwords/reportdownload/v201109/reportDefinition.xsd


How to use this XSD

There are many tools to use to validate XML against an XSD. Here we will show how to use the common command-line tool xmllint to validate against the XSD. First, download the reportDefinition.xsd to a working directory. Next, save some ReportDefinition XML to a file, such as reportDefinition.xml:

<reportDefinition xmlns="https://adwords.google.com/api/adwords/cm/v201109">
 <selector>
   <fields>CampaignId</fields>
   <fields>Id</fields>
   <fields>Impressions</fields>
   <fields>Clicks</fields>
   <fields>Cost</fields>
   <predicates>
     <field>Status</field>
     <operator>IN</operator>
     <values>ENABLED</values>
     <values>PAUSED</values>
   </predicates>
 </selector>
 <reportName>Custom Adgroup Performance Report</reportName>
 <reportType>ADGROUP_PERFORMANCE_REPORT</reportType>
 <dateRangeType>LAST_7_DAYS</dateRangeType>
 <downloadFormat>CSV</downloadFormat>
</reportDefinition>


Now run the following command from the directory you placed these two files in:

$ xmllint --schema reportDefinition.xsd reportDefinition.xml
[xml omitted]
reportDefinition.xml validates

This step verifies that your ReportDefinition XML is well-formed for use with the AdWords API report downloads.

If you have any questions, please post on the forum or attend one of the AdWords API Office Hours Hangouts.