2015-06-21 35 views
0

我试图用C#连接到Onedrive REST API平台,我需要连接的网址是:HTTP邮政Onedrive RESTAPI

“asdfasdfLJLKJLKJK”

和我想要的代码运行是如下:

using System.Net.Http;  

using (var client = new HttpClient())   
{        
var content_new = new FormUrlEncodedContent(new[]{    new KeyValuePair<string, string>("access_token", "asdKJHKJH")}); 

var content = new FormUrlEncodedContent(values); 
client.BaseAddress = new Uri("https://api.onedrive.com/v1.0"); 
client.DefaultRequestHeaders.Accept.Clear(); 
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); 

var response_web = await client.PostAsync("/drive", content_new);    
var responseString = await response_web.Content.ReadAsStringAsync(); 
Console.WriteLine(responseString); 
Console.ReadLine();} 

但它没有一些奇怪的原因,也想知道我是否可以读取PostAsync向服务器发送的数据?我的意思是请求URL,因为这可能也有助于排除故障。

+0

我打电话的地址实际上是:'https://api.onedrive.com/v1.0/drive?access_code="asdf'' – McMilad

回答

1

查看您的请求,您正在驱动器上执行POST操作,OneDrive API不支持该驱动器节点上的操作。

如果您正在创建新文件夹或上传文件,您需要在https://api.onedrive.com/drive/root上执行该操作,或者希望在用户的帐户中执行该操作。

要查找所有支持的操作和示例请求,请参阅OneDrive API resource model