我正在使用 Microsoft Graph 更改联系人的电话。
var defaultContact = await graphClient.Me.Contacts.Request().GetAsync();
mylist.AddRange(defaultContact);
while (defaultContact.NextPageRequest != null)
{
defaultContact = await defaultContact.NextPageRequest.GetAsync();
mylist.AddRange(defaultContact);
}
Run Code Online (Sandbox Code Playgroud)
我有一个联系人列表:mylist
我使用此代码添加新联系人:
await graphClient.Me.Contacts.Request().AddAsync(newcontact);
Run Code Online (Sandbox Code Playgroud)
但我找不到如何使用 Microsoft.Graph 更新或编辑联系人
我在尝试使用此处找到的图形客户端库获取此数据时遇到问题: https: //www.nuget.org/packages/Microsoft.Graph在我的 c# 应用程序中。我知道可以使用此REST API 调用获取数据。
我创建了我的天蓝色应用程序,并为应用程序提供了“读取所有用户邮箱设置”权限,然后单击“授予权限”来应用它们。问题不在于我的身份验证。我能够检索数据。
MicrosoftAuthenticationProvider authProvider =
new MicrosoftAuthenticationProvider(applicationID, applicationSecret, microsoftURL);
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
IGraphServiceUsersCollectionPage users = await graphClient.Users.Request().GetAsync();
foreach (User user in users)
{
//user.MailboxSettings
//returns null, but through intellisense, I can obtain it's attributes
//Microsoft.Graph.MailboxSettings is available in the library's object browser
//graphClient.Users[user.UserPrincipalName].MailboxSettings.Request().GetAsync()
//User.MailboxSettings is not available
}
Run Code Online (Sandbox Code Playgroud)
作为最后的手段,我将使用 REST API,但如果可以的话,我只想使用该库。
我正在尝试通过 Microsoft Graph Api (SDK) 获取驱动器的项目并尝试了以下选项:
_graphServiceClient.Drives[driveInfo.Id].Items.Request().GetAsync():,不幸的是,这会导致错误消息错误消息“请求格式错误或不正确”和代码“invalidRequest”。_graphServiceClient.Drives[driveInfo.Id].Request().GetAsync()但是,如果我执行,我会取回所有驱动器,但Items属性为null.
_graphServiceClient.Drives[driveInfo.Id].Request().Expand(d => d.Items).GetAsync(),这也会导致错误消息“请求格式错误或不正确”和代码“invalidRequest”。
我不知道如何从这里继续,仍在研究中,但目前文档让我一无所知。任何人都成功.Expand()或从云端硬盘获取实际文件?
谢谢,是
我正在.NET Core与C#应用程序一起使用,并且集成了 Azure AD 身份验证。这意味着任何 Azure AD 用户都可以登录此应用程序。现在在某个地方,我想显示当前登录用户的城市、州、国家和其他一些字段值。为此,我使用了Microsoft Graph API,但无法成功获取详细信息。我收到一个错误Request_ResourceNotFound。我使用下面的C#代码来获取当前登录用户的数据。
var clientId = "<CLIENT_ID>"; // I have used my application client id here
var secret = "<CLIENT_SECRET>"; // I have used my client secret here
var domain = "<DOMAIN>"; // I have used domain here
var credentials = new ClientCredential(clientId, secret);
var authContext = new AuthenticationContext($"https://login.microsoftonline.com/{domain}/");
var token = await authContext.AcquireTokenAsync("https://graph.microsoft.com/", credentials);
var graphServiceClient = new GraphServiceClient(new DelegateAuthenticationProvider((requestMessage) =>
{ …Run Code Online (Sandbox Code Playgroud) 我正在尝试下面的请求。按分配计划属性中的 servicePlanId 过滤用户,尝试过滤“电话系统”计划。
https://graph.microsoft.com/beta/users?$filter=assignedPlans/any(x:x/servicePlanId eq 4828c8ec-dc2e-4779-b502-87ac9ce28ab7)
Run Code Online (Sandbox Code Playgroud)
并在响应正文中收到下面给出的错误消息。
"message": "Complex query on property assignedPlans is not supported.",
Run Code Online (Sandbox Code Playgroud)
MS-Graph-Explorer 链接 我如何以这种方式过滤用户?有什么方法可以使用 ms-graph-java-sdk 实现此目的吗?
azure-active-directory microsoft-graph-sdks microsoft-graph-api
我正在掌握Python SDK,之前从未使用过 GraphQL (但我熟悉基本概念)。我能够odata_next_link从响应中检索值,但我不确定如何使用它。我从这里注意到:
您应该在下一页结果的请求中的 @odata.nextLink 属性中包含整个 URL。根据执行查询的 API,@odata.nextLink URL 值将包含 $skiptoken 或 $skip 查询参数。URL 还包含原始请求中存在的所有其他查询参数。不要尝试提取 $skiptoken 或 $skip 值并将其用于不同的请求。
但是,我不确定如何在下一个请求中包含该 URL。目前,我的查询看起来像response = await graph_client.groups.by_group_id(group_id).transitive_members.get()- 我没有看到更改基本网址的选项。我想我可以做这样的事情:
query_params = GroupsRequestBuilder.GroupsRequestBuilderGetQueryParameters(
skip_token = parse_qs(urlparse(response.odata_next_link).query)['$skipToken'][0]
)
request_configuration = GroupsRequestBuilder.GroupsRequestBuilderGetRequestConfiguration(
query_parameters=query_params
)
response = await graph_client.[...].get(request_configuration)
Run Code Online (Sandbox Code Playgroud)
但该报告GroupsRequestBuilder.GroupsRequestBuilderGetQueryParameters.__init__() got an unexpected keyword argument 'skip_token'(如果我尝试命名参数skiptoken或,则类似skipToken)
我正在使用(https://github.com/microsoftgraph/msgraph-sdk-php)Microsoft graph API从Microsoft帐户检索我的邮件.php SDK
我的代码示例如下
<?php
// Autoload files using the Composer autoloader.
require_once __DIR__ . '/vendor/autoload.php';
use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;
//get the access token to access graph api
$tenantId = "XXXXXX";
$clientId = "XXXXXXXXXXXX";
$clientSecret = "XXXXXXXXXXX";
$guzzleClient = new \GuzzleHttp\Client(array('curl' => array( CURLOPT_SSL_VERIFYPEER => false)));
$url = 'https://login.microsoftonline.com/' . $tenantId . '/oauth2/token?api-version=1.0';
$token = json_decode($guzzleClient->post($url, [
'form_params' => [
'client_id' => $clientId,
'client_secret' => $clientSecret,
'resource' => 'https://graph.microsoft.com/',
'grant_type' => 'client_credentials',
],
])->getBody()->getContents()); …Run Code Online (Sandbox Code Playgroud) 最近微软宣布可以发送附件大于4MB的电子邮件。根据文档,我们必须创建草稿,然后上传会话,上传附件,最后发送邮件。
我可以使用以下代码创建草稿:
var confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(clientId)
.WithClientSecret(clientSecret)
.WithTenantId(tenant)
.Build();
var authenticationProvider = new ClientCredentialProvider(confidentialClientApplication);
var graphClient = new GraphServiceClient(authenticationProvider);
var email = new Message
{
Body = new ItemBody
{
Content = i + " Works fine! " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
ContentType = BodyType.Html,
},
Subject = "Test" + (j == 0 ? "" : " " + j),
ToRecipients = recipientList,
Attachments = att
};
Message draft = await graphClient
.Users["test@test.onmicrosoft.com"]
.Messages
.Request()
.AddAsync(mail);
Run Code Online (Sandbox Code Playgroud)
但是当我尝试文档中的片段时:
var …Run Code Online (Sandbox Code Playgroud) c# microsoft-graph-sdks microsoft-graph-mail microsoft-graph-api
我需要通过电子邮件 ID 通过 Microsoft graph 查询获取单个用户详细信息,任何人都可以帮助我,我在 MS 文档中找不到它。
var users = graphServiceClient.Users.Request().GetAsync().GetAwaiter().GetResult();
Run Code Online (Sandbox Code Playgroud)
这只会带来 100 个用户,我需要通过电子邮件获取用户,这样我才能获取特定用户
.NET毛伊岛应用程序,
我正在尝试从 Drive 上的根文件夹获取子级列表...当我使用 MS Learn 中的代码片段时,我在编辑/编译时收到此错误:
“DriveRequestBuilder”不包含“Root”的定义,并且找不到接受“DriveRequestBuilder”类型的第一个参数的可访问扩展方法“Root”(您是否缺少 using 指令或程序集引用?)
我刚刚克隆了一个由微软员工开发的示例项目,并插入了来自 MS Learn 的一段代码。
请在此处获取出现错误的整个项目:
https://github.com/leoderja/DriveRequestBuilder_RootNotDefined.git
错误在于:
MauiAppBasic.csproj 项目 ->
MSALClient 文件夹 -> MSGraphHelper.cs 文件 -> TestRootChildrenAsync 方法
使用 Microsoft.Graph 版本 5.0.0-rc.1
版本:这是一个最小的例子:
using Microsoft.Graph;
GraphServiceClient graphClient = new GraphServiceClient(new HttpClient());
var children = await graphClient.Me.Drive.Root.Children.Request().GetAsync();
Run Code Online (Sandbox Code Playgroud)
问题是 Microsoft.Graph v5.00 rc1。当我设置 v4.50 时,错误消失了。我希望 Microsoft 工作人员在 v5 最终版本发布时更新文档并进行更改。