Microsoft Advertising APIs
Request and Download a Report
-
Create an instance of one of the objects derived from the ReportRequest data object.
The type of object instantiated determines the type of report to request. For example, to request a keyword performance report, create an instance of the KeywordPerformanceReportRequest object.
Note: |
|---|
You must use an object derived from ReportRequest. It is an abstract data type and cannot be instantiated directly.
|
-
Initialize the necessary elements of the report request object. You must initialize both the elements defined by the base
ReportRequest object and the elements for the derived object. Some of these elements are optional and might not be needed in all cases.
-
Create an instance of the SubmitGenerateReportRequest object and initialize the elements of this object with the header and parameter information.
-
Call the SubmitGenerateReport service operation, passing in the
SubmitGenerateReportRequest object.
The SubmitGenerateReport service operation is an asynchronous operation that returns before the report is created. The SubmitGenerateReport service operation returns a SubmitGenerateResponse object. The ReportRequestId element of this object contains a report identifier that you use to determine when the report is finished.
-
Create an instance of the PollGenerateReportRequest object, and then initialize the elements of this class with the header and parameter information.
-
Call the PollGenerateReport service operation repeatedly, passing in the
PollGenerateReportRequest object until the report is created. The PollGenerateReport service operation returns a PollGenerateReportResponse object. The ReportRequestStatus element of this object contains a ReportRequestStatus object that is used to determine the status of the report.
Note: |
|---|
|
Each call to this service operation affects your API quota, so you shouldn't call this service operation very often. Depending on the expected size of the report and your own requirements, you should call this service operation in intervals of every few minutes to as long as every hour. Your own requirements and API quota allowance should be used to determine how often you should call this service operation.
|
-
Stop polling when the
Status element of the ReportRequestStatus object does not contain "Pending".
-
If the
Status element contains "Success", the report was successfully created and can be downloaded from the URL contained in the ReportDownloadUrl element of the ReportRequestStatus object.
-
Any status value other than "Success" or "Pending" is an error.
-
Open a connection to the URL contained in the
ReportDownloadUrl element of the ReportRequestStatus object.
Note: |
|---|
Reports are available only for a short time. When GetReportStatus indicates that the report was successful, you must start the download of the report within five minutes of the call to GetReportStatus. If the download is not started within this time, the report is deleted and must be requested again.
|
-
Download, and then save the file, which is zipped.
-
Unzip the downloaded file, and then save it to the final report file.
For more detailed information about how to request and download a report, see the following topics:
Concepts
Specify Custom Dates in a Report
Report Measures and Columns