Using Net::HTTP to prod google adwords api

C

Chris Roos

Hi,

I've been trying to use Net::HTTP with a SOAP (xml) document to query
google adwords api. The reason for wanting to do this, is that I've
stumbled across a problem with one of the methods when using
adwords4r. I wanted to eliminate adwords4r and soap4r from the
equation, hence trying to manipulate manually.

I've copied the http headers from the output I see when using
adwords4r (code is at bottom of message). Unfortunately, I get a http
302 response rather than the expected xml document.

I'm wondering if there's anything obvious I'm missing?

Chris

-- code --

xml = %%
<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header>
<token env:mustUnderstand="0">MYEMAIL++GBP</token>
<useragent env:mustUnderstand="0">ruby api</useragent>
<password env:mustUnderstand="0">MYPASSWORD</password>
<clientEmail env:mustUnderstand="0">client_1+MYEMAIL</clientEmail>
<email env:mustUnderstand="0">MYEMAIL</email>
</env:Header>
<env:Body>
<getUsageQuotaThisMonth xmlns="https://adwords.google.com/api/adwords/v5">
</getUsageQuotaThisMonth>
</env:Body>
</env:Envelope>
%

require 'net/https'
require 'uri'

url = URI.parse('https://sandbox.google.com/api/adwords/v5/InfoService')
http = Net::HTTP.new(url.host)
http.set_debug_output(STDERR)

request = Net::HTTP::post.new(url.path)
request['Content-Type'] = "text/xml; charset=utf-8"
request['User-Agent'] = "Ruby client"
request['Soapaction'] = "\"\""
request.body = xml
http.start do |sess|
sess.request(request)
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top