[英]Why am I getting this 401 unauthorized error while using Hammock with the Tumblr API to retrieve likes?
Here is the code that I am using: 这是我正在使用的代码:
public static void FetchXML()
{
_url = new Uri("http://api.tumblr.com/v2/blog/" + _username + ".tumblr.com/likes?api_key=REc3Z6l4ZYss11a8lX6KKje0X8Hsi9U77SyaPbQrOBBCGJGA6D");
var client = new RestClient();
client.Authority = _url.ToString();
var request = new RestRequest();
request.AddParameter("limit", "20");
request.AddParameter("offset", _offset.ToString());
var response = client.Request(request);
var content = response.Content.ToString();
var parsedResponse = JsonParser.FromJson(content);
}
If I take the Uri value and paste it into my browser (using a valid Tumblr username) I'm getting the correct Json, but in my application the content of response
is: 如果我采用Uri值并将其粘贴到浏览器中(使用有效的Tumblr用户名),则会得到正确的Json,但是在我的应用程序中,
response
的内容为:
"{\"meta\":{\"status\":401,\"msg\":\"Unauthorized\"},\"response\":[]}"
Anyone have any idea why this is? 有人知道为什么会这样吗? According to the Tumblr API retrieving likes should only need the API key, which I am providing.
根据Tumblr API的检索,喜欢的对象只需要我提供的API密钥。
Hi you can use the below code to get the response. 嗨,您可以使用下面的代码来获取响应。
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
request.Method = "GET";
request.ContentType = "Application/json";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream receive = response.GetResponseStream();
StreamReader reader = new StreamReader(receive, Encoding.UTF8);
string respond = reader.ReadToEnd();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.