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:
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..
WebRequest req = WebRequest.Create("http://api.tumblr.com/v2/blog/" + item + "/avatar/"); WebResponse res = req.GetResponse(); string avatarUrl = res.ResponseUri.ToString();