private static void GetReports() { string authToken = GetAuthToken(); string requestXml = string.Format(@" <?xml version='1.0' encoding='utf-8'?> <soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<soap:Header> <RequestHeader xmlns='https://adwords.google.com/api/adwords/cm/v201109_1/AdGroupService'> <authToken>{0}</authToken> <clientCustomerId>{1}</clientCustomerId> <developerToken>{2}</developerToken> <userAgent>{3}</userAgent> </RequestHeader> </soap:Header> <soap:Body> <get xmlns='https://adwords.google.com/api/adwords/cm/v201109_1/AdGroupService'> <serviceSelector> <fields>id</fields> <fields>url</fields> <fields>approvalStatus</fields> </serviceSelector> </get> </soap:Body> </soap:Envelope>", authToken, "ID", "AUTHTOKEN", "AGENT").Trim(); WebRequest webRequest = HttpWebRequest.Create("https://adwords.google.com/api/adwords/cm/v201109_1/AdGroupService"); //AdGroupCriterionService webRequest.Method = "POST"; webRequest.ContentType = "text/xml; charset=utf-8"; webRequest.Headers.Add("SOAPAction", ""); byte[] postBytes = Encoding.UTF8.GetBytes(requestXml); webRequest.ContentLength = postBytes.Length; using (Stream strmReq = webRequest.GetRequestStream()) { strmReq.Write(postBytes, 0, postBytes.Length); } try { WebResponse response = webRequest.GetResponse(); using (StreamReader reader = new StreamReader(response.GetResponseStream())) { string responseXml = reader.ReadToEnd(); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(responseXml); XmlNamespaceManager xmlns = new XmlNamespaceManager(xDoc.NameTable); xmlns.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/"); xmlns.AddNamespace("v201109_1", "https://adwords.google.com/api/adwords/cm/v201109_1"); XmlElement faultNode = (XmlElement) xDoc.SelectSingleNode("soap:Envelope/soap:Body/soap:Fault", xmlns); if (faultNode != null) { // Something went wrong with API call. Parse faultNode for more details. } else { XmlElement mutateResponseNode = (XmlElement) xDoc.SelectSingleNode("soap:Envelope/soap:Body/v201109:mutateResponse", xmlns); // Parse mutateResponseNode contents to get the campaign id. } } } catch (WebException ex) { throw new ApplicationException("Could not make Api call.", ex); } } -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and discussion group: http://adwordsapi.blogspot.com http://groups.google.com/group/adwords-api =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en