0
我做一些基本的REST/HTTP調用到SharePoint網站上傳文檔。見下面的代碼。的Sharepoint/REST和元數據
這個工程就像一個魅力,但它只能創建一個具有給定的名稱和內容的文件。有沒有辦法通過REST/http界面操作Sharepoint中的元數據?
我也嘗試使用OData協議,這使得很容易改變的元數據,但這需要我添加一個服務引用,並使用生成的類,很漂亮,但不是我所需要的靈活性。有什麼建議麼?
byte[] bytesToSend = // get bytes from a file somewhere
WebRequest req = WebRequest.Create(new Uri("https://mysharepoint/sites/mysite/file.txt"));
req.Method = "PUT";
req.Credentials = new NetworkCredential("USR","passwd","Domain");
MemoryStream ms = new MemoryStream(bytesToSend);
ms.CopyTo(req.GetRequestStream());
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
if (resp.StatusCode.Equals(HttpStatusCode.OK) || resp.StatusCode.Equals(HttpStatusCode.Created))
{ // ... Ok done uploading.
你有沒有嘗試添加標題? – Paparazzi
好吧,不。這顯然是要走的路。只需要找到一些標題名稱和他們的語法。 –
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.headers.aspx http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.contenttype。 ASPX – Paparazzi