我无法使用此代码插入文件的权限:
string URI = String.Format("https://www.googleapis.com/drive/v2/files/{0}/permissions&access_token={1}", fileId, "token");
var request = (HttpWebRequest)HttpWebRequest.Create(URI);
request.Method = "POST";
request.ContentType = "application/json";
string json = "{\"role\": \"reader\",\"type\": \"anyone\"}";
byte[] byteData = new System.Text.ASCIIEncoding().GetBytes(json);
request.ContentLength = byteData.Length;
using (var dataStream = request.GetRequestStream())
{
dataStream.Write(byteData, 0, byteData.Length);
}
var response = (HttpWebResponse)request.GetResponse();
using (var reader = new StreamReader(response.GetResponseStream()))
{
json = reader.ReadToEnd();
}
我收到404错误。有什么问题?
答案 0 :(得分:0)
string URI = String.Format("https://www.googleapis.com/drive/v2/files/{0}/permissions&access_token={1}", fileId, "token");
访问令牌不是字符串"令牌" 它必须是拥有该文件的用户的有效访问令牌。
<强>更新强>
permissions?access_token={1}",
您应该使用?
而不是&
向网址添加参数。甚至不确定你是否可以像使用HTTP Post那样做。
添加信息: