簡體   English   中英

使用Windows應用商店Sharepoint 2010修改列表項

[英]Sharepoint 2010 Modifying list items with Windows Store app

我為此主題奮斗了數周,因此我在這里問:

我為Windows Surface編寫了Windows Store應用程序。 此應用程序應讀取Microsoft ShrePoint 2010列表的條目,對其進行修改或將新值添加到空白字段,然后將修改后的列表上傳到SharePoint。 讀取值沒問題,可以正常工作。 問題是列表條目的上傳。

我發現了很多方法可以做到這一點,但是沒有一種方法可以與Store App一起使用。

有誰知道與C#,Sharepoint 2010和Store App配合使用的方法?

謝謝

我認為,如果您修改鏈接以使用2010 REST API結構,則此示例應該可以在SharePoint 2010中創建列表項。 我沒有針對2010年環境進行測試的方法,但這是我發現做可與SharePoint一起使用的Store Apps的唯一方法。

這將創建一個項目:

string url = "https://YourSite.com/Subsite/";
HttpClient client = new HttpClient(new HttpClientHandler() { UseDefaultCredentials = true });
client.BaseAddress = new System.Uri(url);
client.DefaultRequestHeaders.Clear();
client.DefaultRequestHeaders.Add("X-RequestDigest", digest);
client.DefaultRequestHeaders.Add("X-HTTP-Method", "POST");
HttpContent content = new StringContent("{ '__metadata': { 'type': 'SP.Data.ReportListItem' }, 'Title': 'NewTitle', 'PhotosId': { 'results': [2] }, 'Details': 'Another successful day!' }");
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
content.Headers.ContentType.Parameters.Add(new NameValueHeaderValue("odata", "verbose"));
HttpResponseMessage response = await client.PostAsync("_api/web/lists/GetByTitle('Report')/items", content);
response.EnsureSuccessStatusCode();
if (response.IsSuccessStatusCode)
{
}
else
{
} 

如果將_api / web / lists / GetByTitle('ListName')/ items替換為_vti_bin / ListData.svc / ListName,我認為此示例仍然可以使用。 也可能需要其他調整。 如果可以,我這里僅使用存儲庫提供了每個常見活動的示例:

https://arcandotnet.wordpress.com/2015/04/01/sharepoint-2013-rest-services-using-c-and-the-httpclient-for-windows-store-apps/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM