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=“XML Schema”
xmlns:env=“http://schemas.xmlsoap.org/soap/envelope/”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>
env:Header
MYEMAIL++GBP
ruby api
MYPASSWORD
client_1+MYEMAIL
MYEMAIL
</env:Header>
env:Body
</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