c# - Tumblr avatar request

I'm trying to get the url of a tumblr user's avatar . The problem is, what I get back is not the url, but the image itself. This is the link from which I should get the url:

api.tumblr.com/v2/blog/{blog-identifier}/avatar[/size]

This is how I tried to get the url of the avatar. Note : "item" here is a blog (eg: blog.tumblr.com)

WebRequest req = WebRequest.Create("http://api.tumblr.com/v2/blog/" + item + "/avatar/");
WebResponse res = req.GetResponse();
StreamReader rd = new StreamReader(res.GetResponseStream(),Encoding.ASCII);
var end = rd.ReadToEnd();

I read an response on a forum which said :

the /avatar route redirects you to the avatar url.

Don't follow the redirect and pull the url out of the Location header or the body of the request, which contains the same url.

But I don't know how to do that, can you help me ? There are some answers to some similar questions to mine, but those are for a different programming language..

Answers


WebRequest req = WebRequest.Create("http://api.tumblr.com/v2/blog/" + item + "/avatar/");
            WebResponse res = req.GetResponse();
            string avatarUrl = res.ResponseUri.ToString();

Need Your Help

Replace String dynamically XSLT 1.0

xml xslt-1.0

I am facing an issue where I have to replace string dynamically in loop. I have to convert an XML into HTML.

Why won't my UITableView show the data?

ios iphone xml uitableview load

Here is my issue. I have a screen in a tab bar application that display's a search bar, and a UITableView. When you first open the tab, the UITableView is empty. After you enter a search, the iPhon...