【发布时间】:2019-04-10 05:12:42
【问题描述】:
我正在使用 SharePoint 客户端对象模型在线登录 SharePoint,然后检索列表以获取 SharePoint 上的文档。然后我想获取这些文档的共享链接。这是我目前的做法:
using (var context = new ClientContext(siteURL))
{
context.Credentials = new SharePointOnlineCredentials(login, securePassword);
context.Load(context.Web, w => w.Title);
context.ExecuteQuery();
List docList = context.Web.Lists.GetByTitle("Documents");
context.Load(docList);
// This creates a CamlQuery that has a RowLimit of 100, and also specifies Scope="RecursiveAll"
// so that it grabs all list items, regardless of the folder they are in.
CamlQuery query = CamlQuery.CreateAllItemsQuery(100);
ListItemCollection items = docList.GetItems(query);
// Retrieve all items in the ListItemCollection from List.GetItems(Query).
context.Load(items);
context.ExecuteQuery();
foreach (ListItem listItem in items)
{
var sharingInfo = ObjectSharingInformation.GetListItemSharingInformation(
context, docList.Id, listItem.Id, false, true, false, true, true, true);
context.Load(sharingInfo);
context.ExecuteQuery();
string str = sharingInfo.AnonymousEditLink;
}
}
这里的问题是sharingInfo 对象有一个名为 AnonymousEditLink 的字段,但它是一个空字符串。我不确定为什么这是一个空字符串。这是生成共享链接的正确方法吗?
我也试过这个(但没有用):
var sharingInfo = ObjectSharingInformation.GetObjectSharingInformation(
context, listItem, false, true, false, true, true, true, true);
【问题讨论】:
-
你有什么运气吗?当我提出请求时,即使它显示在 UI 中,它也不会显示域外的用户
标签: asp.net sharepoint sharepoint-online csom