无法从我的包装盒帐户访问根文件夹,我收到错误消息:
{System.Net.WebException:远程服务器返回错误:(403)禁止 在System.Net.HttpWebRequest.GetResponse()
在----。cs:第110行的Program.Main(String [] args)中
我错过了什么吗?
response = null;
data = new StringBuilder();
byteArray = Encoding.UTF8.GetBytes(data.ToString());
// Setup the Request
url_folder_0 = "https://api.box.com/2.0/folders/0/"
request = (HttpWebRequest)WebRequest.Create(url_folder_0);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
request.Headers.Add("Authorization: Bearer " + accessToken);
// Write data
postStream = request.GetRequestStream();
postStream.Write(byteArray, 0, byteArray.Length);
postStream.Close();
// Send Request & Get Response
response = (HttpWebResponse)request.GetResponse();
答案 0 :(得分:1)
要获取有关/ folders / 0的信息,您需要执行GET请求。
更改行
request.Method = "POST";
到
request.Method = "GET";
这是Box的API的CRUD解码器环
POST = Create
GET = Read
PUT = Update
DELETE = Delete