This page provides information on the required SOAP XML request headers, and the headers that are returned in response.
Required Request Headers
All API SOAP calls must have a <RequestHeader>
element in the header; this element is defined in all the service WSDLs. The client libraries provide
methods to add this header for you, using the values that you supply. Here is a description of all the elements of <RequestHeader>
:
Element | Description |
---|---|
<networkCode> |
The network code of the network being addressed. Network codes are required when making all requests except Be sure that you only use a network code available to your account login. You can find the code on the Google Ad Manager website for your account, on the Admin > Network Settings page next to "Network code". |
<applicationName> |
An arbitrary string name identifying your application. This will be shown in Google's log files. For example: "My Inventory Application" or "App_1". |
Note: Every request your application sends to the Ad Manager API must include an OAuth2 access token. Pass the token in the HTTP header as: Authorization: Bearer YOUR_ACCESS_TOKEN
.
The following code is an example of a SOAP request call to getAdUnitsByStatement()
looking for the root AdUnit
.
<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Header> <ns1:RequestHeader soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns1="https://www.google.com/apis/ads/publisher/v202411"> <ns1:networkCode>123456</ns1:networkCode> <ns1:applicationName>DfpApi-Java-2.1.0-dfp_test</ns1:applicationName> </ns1:RequestHeader> </soapenv:Header> <soapenv:Body> <getAdUnitsByStatement xmlns="https://www.google.com/apis/ads/publisher/v202411"> <filterStatement> <query>WHERE parentId IS NULL LIMIT 500</query> </filterStatement> </getAdUnitsByStatement> </soapenv:Body> </soapenv:Envelope>
Note: If your SOAP request causes an Unmarshalling error
, see Common Errors for troubleshooting tips.
Response Headers
All responses returned from the API include the following header elements. As a best practice, we recommend that you log these values.
Element | Description |
---|---|
<requestId> |
Uniquely identifies this request. If you have any support issues, sending us this ID will enable us to find your request more easily. |
<responseTime> |
Elapsed time between the web service receiving the request and sending the response. |
Example Response
The following code shows an example of a SOAP response for the previous request.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <ResponseHeader xmlns="https://www.google.com/apis/ads/publisher/v202411"> <requestId>xxxxxxxxxxxxxxxxxxxx</requestId> <responseTime>1063</responseTime> </ResponseHeader> </soap:Header> <soap:Body> <getAdUnitsByStatementResponse xmlns="https://www.google.com/apis/ads/publisher/v202411"> <rval> <totalResultSetSize>1</totalResultSetSize> <startIndex>0</startIndex> <results> <id>2372</id> <name>RootAdUnit</name> <description></description> <targetWindow>TOP</targetWindow> <status>ACTIVE</status> <adUnitCode>1002372</adUnitCode> <inheritedAdSenseSettings> <value> <adSenseEnabled>true</adSenseEnabled> <borderColor>FFFFFF</borderColor> <titleColor>0000FF</titleColor> <backgroundColor>FFFFFF</backgroundColor> <textColor>000000</textColor> <urlColor>008000</urlColor> <adType>TEXT_AND_IMAGE</adType> <borderStyle>DEFAULT</borderStyle> <fontFamily>DEFAULT</fontFamily> <fontSize>DEFAULT</fontSize> </value> </inheritedAdSenseSettings> </results> </rval> </getAdUnitsByStatementResponse> </soap:Body> </soap:Envelope>