Re: MCM service - GetClientCustomerId : The remote server returned an error: (500) Internal Server Error.
Hello Kiran, A correct request should look like: ?xml version=1.0 encoding=UTF-8? env:Envelope xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xsi= http://www.w3.org/2001/XMLSchema-instance; xmlns:wsdl= https://adwords.google.com/api/adwords/mcm/v201209; xmlns:env= http://schemas.xmlsoap.org/soap/envelope/; xmlns:ns0= https://adwords.google.com/api/adwords/cm/v201209; env:Header wsdl:RequestHeader xmlns= https://adwords.google.com/api/adwords/cm/v201209; userAgentuser-agent/userAgent developerTokendeveloper-token/developerToken authTokenauth-token/authToken /wsdl:RequestHeader /env:Header env:Body get xmlns=https://adwords.google.com/api/adwords/mcm/v201209; serviceSelector ns0:fieldsLogin/ns0:fields ns0:fieldsCustomerId/ns0:fields ns0:fieldsName/ns0:fields /serviceSelector /get /env:Body /env:Envelope Note selector is from default (mcm) namespace while all the fields are from the cm namespace. Please consider using our client libraries which handle this kind of issues for you. -Danial, AdWords API Team. On Wednesday, September 26, 2012 4:45:41 PM UTC+4, Kiran wrote: Hi, We have a requirement in our project to get Client Customer ID. For this we are calling AdWords API v201206 : https://adwords.google.com/api/adwords/mcm/v201206. We are getting following error from the service. Kindly let us know if anything is missing in code posted below. Kindly note : We are following approach of calling AdWords API v201206 with C# without using the AdWords API dotnet client library. Reference : https://code.google.com/p/google-api-adwords-dotnet/wiki/NoClientLibrary ERROR MSG : The remote server returned an error: (500) Internal Server Error. DETAILS : System.Net.WebException was caught Message=The remote server returned an error: (500) Internal Server Error. Source=System StackTrace: at System.Net.HttpWebRequest.GetResponse() at DataSync.Component.GoogleClientCustomerIdManager.GetClientCustomerId() CODE: public static void GetClientCustomerId() { string authToken = GetAuthToken(); string developerToken = GetDeveloperToken(); string userAgent = GetUserAgent(); 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/mcm/v201206' authToken{0}/authToken developerToken{1}/developerToken userAgent{2}/userAgent /RequestHeader /soap:Header soap:Body get xmlns=' https://adwords.google.com/api/adwords/mcm/v201206' serviceSelector fieldsLogin/fields fieldsCustomerId/fields fieldsName/fields /serviceSelector /get /soap:Body /soap:Envelope, authToken, developerToken, userAgent).Trim(); WebRequest webRequest = HttpWebRequest.Create( https://adwords.google.com/api/adwords/mcm/v201206/ManagedCustomerService ); 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(v201206, https://adwords.google.com/api/adwords/mcm/v201206;); XmlElement faultNode =
Re: MCM service - GetClientCustomerId : The remote server returned an error: (500) Internal Server Error.
Hi, I'm facing the same problem exactly. Did you get this to work? Cheers, Bernardo Quarta-feira, 26 de Setembro de 2012 13:45:41 UTC+1, Kiran escreveu: Hi, We have a requirement in our project to get Client Customer ID. For this we are calling AdWords API v201206 : https://adwords.google.com/api/adwords/mcm/v201206. We are getting following error from the service. Kindly let us know if anything is missing in code posted below. Kindly note : We are following approach of calling AdWords API v201206 with C# without using the AdWords API dotnet client library. Reference : https://code.google.com/p/google-api-adwords-dotnet/wiki/NoClientLibrary ERROR MSG : The remote server returned an error: (500) Internal Server Error. DETAILS : System.Net.WebException was caught Message=The remote server returned an error: (500) Internal Server Error. Source=System StackTrace: at System.Net.HttpWebRequest.GetResponse() at DataSync.Component.GoogleClientCustomerIdManager.GetClientCustomerId() CODE: public static void GetClientCustomerId() { string authToken = GetAuthToken(); string developerToken = GetDeveloperToken(); string userAgent = GetUserAgent(); 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/mcm/v201206' authToken{0}/authToken developerToken{1}/developerToken userAgent{2}/userAgent /RequestHeader /soap:Header soap:Body get xmlns=' https://adwords.google.com/api/adwords/mcm/v201206' serviceSelector fieldsLogin/fields fieldsCustomerId/fields fieldsName/fields /serviceSelector /get /soap:Body /soap:Envelope, authToken, developerToken, userAgent).Trim(); WebRequest webRequest = HttpWebRequest.Create( https://adwords.google.com/api/adwords/mcm/v201206/ManagedCustomerService ); 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(v201206, https://adwords.google.com/api/adwords/mcm/v201206;); 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/v201206: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
MCM service - GetClientCustomerId : The remote server returned an error: (500) Internal Server Error.
Hi, We have a requirement in our project to get Client Customer ID. For this we are calling AdWords API v201206 : https://adwords.google.com/api/adwords/mcm/v201206. We are getting following error from the service. Kindly let us know if anything is missing in code posted below. Kindly note : We are following approach of calling AdWords API v201206 with C# without using the AdWords API dotnet client library. Reference : https://code.google.com/p/google-api-adwords-dotnet/wiki/NoClientLibrary ERROR MSG : The remote server returned an error: (500) Internal Server Error. DETAILS : System.Net.WebException was caught Message=The remote server returned an error: (500) Internal Server Error. Source=System StackTrace: at System.Net.HttpWebRequest.GetResponse() at DataSync.Component.GoogleClientCustomerIdManager.GetClientCustomerId() CODE: public static void GetClientCustomerId() { string authToken = GetAuthToken(); string developerToken = GetDeveloperToken(); string userAgent = GetUserAgent(); 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/mcm/v201206' authToken{0}/authToken developerToken{1}/developerToken userAgent{2}/userAgent /RequestHeader /soap:Header soap:Body get xmlns='https://adwords.google.com/api/adwords/mcm/v201206' serviceSelector fieldsLogin/fields fieldsCustomerId/fields fieldsName/fields /serviceSelector /get /soap:Body /soap:Envelope, authToken, developerToken, userAgent).Trim(); WebRequest webRequest = HttpWebRequest.Create( https://adwords.google.com/api/adwords/mcm/v201206/ManagedCustomerService;); 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(v201206, https://adwords.google.com/api/adwords/mcm/v201206;); 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/v201206: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