MS GraphServiceClient在SharePoint中添加事件列表项获取无效参数
C#代码(下)是我正在测试的。获得权限等。获取列表项目测试正在工作。在下面的ListItem对象中,ADDASYNC方法具有以下有效载荷,即获得无效的参数。标题,开始时间和结束时间是必需的字段。我无法在事件列表上找到MS Graph的任何特定内容。我正在使用ListItem对象,但不确定其中的不良论点是什么。任何帮助都将受到赞赏。请指教。 tia
_scopes = new[] { "https://graph.microsoft.com/.default" };
// using Azure.Identity;
var options = new TokenCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};
var clientSecretCredential = new ClientSecretCredential(
_graphSettings.TenantId, _graphSettings.ClientId, _graphSettings.ClientSecret, options);
_graphClient = new GraphServiceClient(clientSecretCredential, _scopes);
var listItem = new ListItem
{
Fields = new FieldValueSet
{
AdditionalData = new Dictionary<string, object>()
{
{"Title", "MS Graph API Test"},
{"Description", "Proof of Concept Test"},
{"Location", "East Club" },
{"Start Time", "2022–06–28T09:00:00" },
{"End Time", "2022–06–28T15:00:00" }
}
}
};
await _graphClient.Sites["{_graphSettings.SharepointSiteId}"].Lists["{_graphSettings.EventListId}"].Items
.Request()
.AddAsync(listItem);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
操作前将其写入SharePoint网站。
给出
sites.ReadWrite.all
应用程序许可,如果是用户,请确保sites.readwrite.All授予授权权限。还请确保同时授予permissions。
检查是否需要在请求标题中给出content_type。
尝试不给出开始和结束日期。
参考重新检查: listItem-create |微软文档
Graph Explorer
write to the sharepoint site before operation.
give

Sites.ReadWrite.All
Application permission , if it is user make sure Sites.ReadWrite.All delegated permission is given.Also make sure to grant permsissions for the same.
Check if Content_Type needs to be given in request headers.
try without giving start and end date.
Reference: listitem-create | microsoft docs