# Using Net::HTTP to prod google adwords api

**URL:** <https://www.ruby-forum.com/t/using-net-http-to-prod-google-adwords-api/68535>\
**Category:** Ruby\
**Created:** [September 13, 2006, 1:47pm UTC](https://www.ruby-forum.com/t/using-net-http-to-prod-google-adwords-api/68535 "2006-09-13T13:47:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![crenner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/278dde/32.png) [@crenner](https://www.ruby-forum.com/u/crenner)\
**Post date:** [September 13, 2006, 1:47pm UTC](https://www.ruby-forum.com/t/using-net-http-to-prod-google-adwords-api/68535/1 "2006-09-13T13:47:05Z")

</div>

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](http://www.w3.org/2001/XMLSchema)”  
xmlns:env=“[http://schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)”  
xmlns:xsi=“[http://www.w3.org/2001/XMLSchema-instance](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](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
