将列表项上传到列表后,我尝试向列表项上的自定义列添加值。我可以将项目放入列表中,我可以查询列表并取回项目的数据,但是当我尝试为额外字段添加数据时,出现以下Microsoft.SharePoint.Client.InvalidClientQueryException错误:
找到了一个没有类型名称的值,并且没有预期的类型可用。当指定模型时,有效载荷中的每个值都必须具有一个类型,该类型可以在有效载荷中指定、由调用者显式指定或从父值隐式推断。
我不确定错误消息所指的值或模型。这是我的代码:
var item = await graphClient
.Drives[driveId]
.Root.ItemWithPath(fileName)
.ListItem.Request()
.Select("WebURL,Fields,SharepointIds")
.Expand("Fields")
.GetAsync();
var fieldVals = await graphClient
.Sites[SPUrl + ":"]
.Sites[SpPath + ":"]
.Lists[libId]
.Items[item.SharepointIds.ListItemId]
.Fields
.Request()
.GetAsync();
fieldVals.AdditionalData.Add("Phase",
JsonConvert.SerializeObject(tags));
await graphClient
.Drives[driveId]
.Root
.ItemWithPath(fileName)
.ListItem
.Fields
.Request()
.UpdateAsync(fieldVals);
Run Code Online (Sandbox Code Playgroud)
最初,当我在做时,fieldVals.AdditionalData.Add()我有“阶段”和一个列表(字符串),这导致未设置 OData 字段类型的错误,但我没有在文档中找到任何说明预期 OData 字段值是什么的地方。我尝试将其设置为microsoft.graph.fieldValueSet但没有用。
我正在尝试更新允许多个选项作为复选框的选择列。
c# sharepoint-online microsoft-graph-sdks microsoft-graph-api
我在 C# 中使用 Graph SDK 来阅读邮件消息,我能够做到这一点。我想要我的邮件消息的 Mime 内容。我们如何使用 SDK 在我的请求中传递 $value。
示例代码:
mails = await graphserviceclient
.Me
.Messages
.Request()
.Top(2)
.GetAsync();
Run Code Online (Sandbox Code Playgroud)
请让我知道我们如何在使用 graphserviceclient 的 C# 代码中传递 $value。
c# microsoft-graph-sdks microsoft-graph-mail microsoft-graph-api
我的 C# 程序使用 Microsoft.Graph Nuget。并且它需要能够确保它具有正确的 Microsoft Graph 应用程序权限。
我知道如何在 AD 中添加权限,但我希望我的程序能够测试它是否具有所需的权限。
我想要实现的目标的示例:
var graphClient = new GraphServiceClient(authenticationProvider);
if(!graphClient.GetPermissions().Contains("AdministrativeUnit.Read.All"))
{
throw new Exception("Missing Permission AdministrativeUnit.Read.All")
}
Run Code Online (Sandbox Code Playgroud)
提前致谢 !
c# azure-active-directory microsoft-graph-sdks microsoft-graph-api
我正在按照Microsoft Graph 教程从 C# 创建聊天消息并将其发送到 Microsoft Teams 频道。
但是,在尝试创建对象时按照第一个示例时出现错误ChatMessage。( var chatMessage = new ChatMessage...) 的错误是:
找不到类型或命名空间名称“ChatMessage”(您是否缺少 using 指令或程序集引用?)
我已经在我的项目中添加了以下引用,但它们似乎都不包含ChatMessage类定义:
Microsoft.GraphMicrosoft.Graph.CoreMicrosoft.Graph.AuthChatMessage文档为我提供了有关资源类型的更多信息ChatMessage,但没有告诉我应该从哪里获取它。
我发现的唯一的其他东西是Windows.ApplicationModel.Chat.ChatMessage,但我在 Nuget 中找不到windows.applicationmodel.chat,而且我不确定这是否真的正确,因为图形教程页面上没有提及它。
为了能够使用ChatMessage教程中的对象,我做错了什么?
c# microsoft-graph-sdks microsoft-graph-teams microsoft-graph-api
我想通过 graph api 或 sdk 为整个 b2c 实例创建“用户自定义属性”。就像我按照下面引用的 ms文档通过 Azure 门户所做的那样。
1. Sign in to the Azure portal as the global administrator of your Azure AD B2C tenant.
2. Make sure you're using the directory that contains your Azure AD B2C tenant by switching to it in the top-right corner of the Azure portal.
3. Select your subscription information, and then select Switch Directory.
4. Choose All services in the top-left corner of the Azure portal, search for …Run Code Online (Sandbox Code Playgroud) 我想在我的项目中使用 PageIterator,它工作得很好,直到我想从 AzureAD 中取出组成员。无论我做什么,PageIterator 都会失败并显示“The Parsable does not contains a collection property”。
List<User> users = new();
var result = await graphClient.Groups[groupId].Members.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Top = 2;
// I only do this to force pageing, will not be on final version
});
var pageIterator = PageIterator<User, DirectoryObjectCollectionResponse>
.CreatePageIterator(graphClient, result,
(m) =>
{
users.Add(m);
return true;
});
await pageIterator.IterateAsync();
Run Code Online (Sandbox Code Playgroud)
我的代码强制执行 2 项。这只是因为我绝望地试图找出我的代码出了什么问题。
我对这里出了什么问题一无所知,任何帮助都会很棒。
c# asp.net-core microsoft-graph-sdks microsoft-graph-api graphserviceclient
此 AAD powershell 可以轻松列出用户的扩展属性:
> Get-AzureADUser -ObjectId 50413382@wingtiptoys.com |select -ExpandProperty ExtensionProperty
Key Value
--- -----
odata.metadata https://graph.windows.net/d29b7a9b-6edb-4720-99a8-3c5c6c3eeeb0/$metadata#directoryObjects/@Element
odata.type Microsoft.DirectoryServices.User
createdDateTime
employeeId 50413382
onPremisesDistinguishedName
thumbnailPhoto@odata.mediaEditLink directoryObjects/8cc715a1-0698-4d1a-8f49-441a84b6dbc4/Microsoft.DirectoryServices.User/thumbnailPhoto
thumbnailPhoto@odata.mediaContentType image/Jpeg
userIdentities []
extension_10a03227b5f146ad8a0087cf0bafd627_division |30103611|50435526|50230396|10192257|86009851
extension_10a03227b5f146ad8a0087cf0bafd627_company wingtiptoys Inc.
extension_10a03227b5f146ad8a0087cf0bafd627_extensionAttribute10 GF
extension_10a03227b5f146ad8a0087cf0bafd627_employeeID 50413382
extension_10a03227b5f146ad8a0087cf0bafd627_cn 50413382
extension_10a03227b5f146ad8a0087cf0bafd627_extensionAttribute8 wingtiptoys Inc. Inc.
extension_10a03227b5f146ad8a0087cf0bafd627_extensionAttribute7 Chuck
extension_10a03227b5f146ad8a0087cf0bafd627_extensionAttribute6 US11
extension_10a03227b5f146ad8a0087cf0bafd627_extensionAttribute5 US1-Rochester, NY- Site
extension_10a03227b5f146ad8a0087cf0bafd627_extensionAttribute4 USC
extension_10a03227b5f146ad8a0087cf0bafd627_extensionAttribute2 Regular
extension_10a03227b5f146ad8a0087cf0bafd627_employeeType ARR
Run Code Online (Sandbox Code Playgroud)
我现在有一个请求,将这种显示构建到经过身份验证的网页中,在前面的页面中,有人可以输入该对象 ID,并使用 Microsoft Graph 客户端 SDK 在屏幕上查看该输出。
关键问题是我无法对扩展属性列表进行硬编码。我只需要列出该特定用户的内容。
我已经找到了如何在知道扩展属性的名称后获取其值,但是如何在不提前知道属性名称的情况下获取上面的属性列表呢?(-ExpandProperty ExtensionPropertyPowerShell 的一部分)
我尝试通过图形浏览器获取这些数据,但遇到了困难。我试过了:
/v1.0/me/?$select=id&$expand=extensions (返回一个空的扩展元素)/v1.0/me/?$select=onPremisesExtensionAttributes(返回部分属性(但不是全部))我正在尝试使用 Microsoft Graph (C# SDK) 在 SharePoint 中的现有文件夹下创建一个文件夹。我知道使用 Graph API 时在 SharePoint 或 OneDrive 上创建文件夹应该是相同的,但我仍然找不到任何好的在线参考。我找到的唯一一篇文章是一篇旧文章,其中只有一个 JavaScript 示例。
我有一个根文件夹A,我想B在A.
这是代码:
var driveRequestBuilder = graphClient
.Sites[SharePointSiteId]
.Lists[ListId]
.Drive;
var folderRequestBuilder = driveRequestBuilder
.Root
.ItemWithPath("A");
var folderDriveItem = folderRequestBuilder
.Request()
.GetAsync()
.Result; // This returns the root folder "A"'s info
var subFolderDriveItem = new DriveItem()
{
Name = "B",
Folder = folderDriveItem.Folder
};
var result = folderRequestBuilder
.Request()
.CreateAsync(subFolderDriveItem)
.Result;
Run Code Online (Sandbox Code Playgroud)
最后一行代码抛出一个异常AggregateException(因为 TPL),其中包含内部异常:
var …Run Code Online (Sandbox Code Playgroud) 我想邀请我们的 Active Directory/租户中的用户。为此,请使用 Microsoft Graph API。代码使用如下
IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(clientId)
.WithTenantId(tenantID)
.WithClientSecret(clientSecret)
.Build();
ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication);
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
var invitation = new Invitation
{
InvitedUserEmailAddress = "myemailaddress@gmail.com",
InviteRedirectUrl = "https://myapp.com"
};
await graphClient.Invitations
.Request()
.AddAsync(invitation);
Run Code Online (Sandbox Code Playgroud)
之后,我可以在 Azure 的 Active Directory 门户中看到该用户。但没有收到邀请电子邮件。
但是,当我从 Azure 门户单击“重新发送邀请”时,就会收到邀请电子邮件。
请您指导一下,为什么从 API 发送邀请时没有收到邀请电子邮件?
c# azure-active-directory microsoft-graph-sdks microsoft-graph-api
根据https://docs.microsoft.com/en-us/graph/api/resources/groups-overview?view=graph-rest-1.0上的在线文档,有四个 AAD 组:Office365、安全性、电子邮件-启用的安全性和分发。
我正在使用以下内容列出组:
graphGroupsPages = await graphServiceClient.Groups
.Request()
//.Filter(????) <= if yes, what should it be?
.GetAsync();
Run Code Online (Sandbox Code Playgroud)
我已经看到了如何列出 Office365(统一)组的示例。
如何仅列出安全组?
azure-active-directory azure-ad-graph-api microsoft-graph-sdks microsoft-graph-api