# Problem with Flickr API and net/http

**URL:** <https://www.ruby-forum.com/t/problem-with-flickr-api-and-net-http/172268>\
**Category:** Ruby\
**Created:** [July 18, 2009, 4:20am UTC](https://www.ruby-forum.com/t/problem-with-flickr-api-and-net-http/172268 "2009-07-18T04:20:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pinkman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/41988e/32.png) [@pinkman](https://www.ruby-forum.com/u/pinkman)\
**Post date:** [July 18, 2009, 4:20am UTC](https://www.ruby-forum.com/t/problem-with-flickr-api-and-net-http/172268/1 "2009-07-18T04:20:26Z")

</div>

I’m writing an app that uses the flickr api via http requests. I can’t  
figure out if the problem I’m having is the way I’m implementing this  
with net/http or simply a problem with the flickr api. My code looks  
like this:

xml\_data = Net::HTTP.get\_response(URI.parse(url)).body  
Hpricot(xml\_data)

I know the url is valid, because I can paste the url directly in to my  
browser and I get valid xml from flickr. But when I issue this code in  
my app, I get a blank response. xml\_data is an empty string every time  
and I can’t figure out why. Am I requesting a response incorrectly?  
Anyone have any idea?

-Kyle

---

<div class="post-metadata">

**Author:** ![pinkman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/41988e/32.png) [@pinkman](https://www.ruby-forum.com/u/pinkman)\
**Post date:** [July 19, 2009, 9:01pm UTC](https://www.ruby-forum.com/t/problem-with-flickr-api-and-net-http/172268/2 "2009-07-19T21:01:51Z")

</div>

Anyone have any problems with receiving blank responses from a Net::HTTP  
request but then get a valid response when issuing the request in a  
browser?

---

<div class="post-metadata">

**Author:** ![pinkman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/41988e/32.png) [@pinkman](https://www.ruby-forum.com/u/pinkman)\
**Post date:** [July 20, 2009, 3:00am UTC](https://www.ruby-forum.com/t/problem-with-flickr-api-and-net-http/172268/3 "2009-07-20T03:00:59Z")

</div>

Kyle Peyton wrote:

> my app, I get a blank response. xml\_data is an empty string every time  
> and I can’t figure out why. Am I requesting a response incorrectly?  
> Anyone have any idea?

Take a look at the HTTP response code (call .code instead of .body). If  
it is in the 3xx range the server is redirecting you to a different URI.  
A browser usually follows these redirects automatically.

-Matthias
