使用RestSharp post
我想使用restsharp库提供的类来post一个txt文件到skydrive,可是不知道restsharp怎么用。。网上的示例又看得不是很明白,试了一天了纠结了一天了,希望哪位大侠能指点一二。。。微软官方给的用REST put和post到skydrive的说明:
PUT https://apis.live.net/v5.0/me/skydrive/files/HelloWorld.txt?access_token=ACCESS_TOKEN
Hello, World!
POST https://apis.live.net/v5.0/me/skydrive/files?access_token=ACCESS_TOKEN
Content-Type: multipart/form-data; boundary=A300x
--A300x
Content-Disposition: form-data; name="file"; filename="HelloWorld.txt"
Content-Type: application/octet-stream
Hello, World!
--A300x--
//test1
string str = string.Format("https://apis.live.net/v5.0/me/skydrive/files/test.txt?access_token={0}", client.Session.AccessToken);
RestRequest request = new RestRequest(str, Method.PUT);
//request.AddBody("ok");//添加这行代码后运行会提示bad request
//test2
//string str = string.Format("https://apis.live.net/v5.0/me/skydrive/files?access_token={0}", client.Session.AccessToken);
//RestRequest request = new RestRequest(str, Method.POST);
//request.AddParameter("Content-Type", "multipart/form-data;boundary=A300x");//从这开始就不知道怎么写了,试着添加其他参数都不行。。
RestClient restClient = new RestClient();
//.........