The remote server returned an error: (404) Not Found.

313 views
Skip to first unread message

vad_la

unread,
Mar 26, 2009, 3:51:46 PM3/26/09
to AdWords API Forum
I am getting this error message on HttpWebRequest.GetResponse

Here is my xml string (sXML):

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<SOAP:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns="https://
adwords.google.com/api/adwords/v13">
<SOAP:Header>
<email>xxxx...@gmail.com</email>
<password>xxx</password>
<clientEmail>client_1...@gmail.com</clientEmail>
<developerToken>xxxx...@gmail.com++USD</developerToken>
</SOAP:Header>
<SOAP:Body>
<addCampaign>
<campaign>
<budgetAmount>100000</budgetAmount>
<budgetPeriod>Daily</budgetPeriod>
<geoTargeting>
<countryTargets>
<countries>US</countries>
</countryTargets>
</geoTargeting>
<languageTargeting>
<languages>en</languages>
</languageTargeting>
<name>Simple Campaign</name>
<networkTargeting>
<networkTypes>SearchNetwork</networkTypes>
<networkTypes>ContentNetwork</networkTypes>
</networkTargeting>
<schedule>
<intevals>
<day>Monday</day>
<endHour>17</endHour>
<endMinute>0</endMinute>
<multiplier>1</multiplier>
<startHour>8</startHour>
<startMinute>0</startMinute>
</intevals>
<intevals>
<day>Friday</day>
<endHour>17</endHour>
<endMinute>0</endMinute>
<multiplier>1</multiplier>
<startHour>8</startHour>
<startMinute>0</startMinute>
</intevals>
<status>Enabled</status>
</schedule>
<status>Active</status>
</campaign>
</addCampaign>
</SOAP:Body>
</SOAP:Envelope>


Here is my code:

Public Function CreateCampaign() As Boolean

Try

Dim ASCIIEnc As New System.Text.ASCIIEncoding
Dim bPostData As Byte() = Text.Encoding.UTF8.GetBytes
(sXML)

Dim HttpReq As HttpWebRequest, sServerResponse As String =
""

HttpReq = HttpWebRequest.Create("https://
sandbox.google.com")

HttpReq.Timeout = 60000
HttpReq.Method = "POST"
HttpReq.ContentType = "text/xml"
HttpReq.ContentLength = bPostData.Length
HttpReq.GetRequestStream.Write(bPostData, 0,
bPostData.Length)

Dim ReadBuffer(bPostData.Length) As Byte, ReadCount As
Integer = 0
Dim RespStream As Stream =
HttpReq.GetResponse.GetResponseStream()
Do
ReadCount = RespStream.Read(ReadBuffer, 0,
ReadBuffer.Length)
sServerResponse &= ASCIIEnc.GetString(ReadBuffer, 0,
ReadCount)
Loop While ReadCount > 0
RespStream.Close()

Return True
Catch ex As Exception

End Try
Return False
End Function

AdWords API Advisor

unread,
Mar 26, 2009, 6:04:28 PM3/26/09
to AdWords API Forum
Hello,

You're not POSTing to an actual SOAP endpoint. The URL for the
CampaignService endpoint in the Sandbox environment is

https://sandbox.google.com/api/adwords/v13/CampaignService

Assuming you're using VB.NET (which, based on your code, I'm guessing
you are) you really should consider either using the AdWords API .NET
Client Library (http://code.google.com/p/google-api-adwords-dotnet/)
or at the very least generating your own stub .NET classes from the
WSDL definitions using VisualStudio's Add Web Reference... tool.
Manually constructing an XML string and sending it with HttpWebRequest
is a very roundabout way of accessing SOAP services.

Cheers,
-Jeff Posnick, AdWords API Team


On Mar 26, 3:51 pm, vad_la <vadim.rapopor...@gmail.com> wrote:
> I am getting this error message on HttpWebRequest.GetResponse
>
> Here is my xml string (sXML):
>
> <?xml version="1.0" encoding="utf-8" standalone="no"?>
> <SOAP:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns="https://
> adwords.google.com/api/adwords/v13">
>   <SOAP:Header>
>     <email>xxxx....@gmail.com</email>
>     <password>xxx</password>
>     <clientEmail>client_1+xxxx....@gmail.com</clientEmail>
>     <developerToken>xxxx....@gmail.com++USD</developerToken>
Reply all
Reply to author
Forward
0 new messages