久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

C# 中的 Microsoft Graph api 代碼僅顯示有限數(shù)量的用

Microsoft Graph api code in C# displays only limited number of users(C# 中的 Microsoft Graph api 代碼僅顯示有限數(shù)量的用戶(hù))
本文介紹了C# 中的 Microsoft Graph api 代碼僅顯示有限數(shù)量的用戶(hù)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

限時(shí)送ChatGPT賬號(hào)..

我在 Microsoft Graph Api 代碼下運(yùn)行:

I am running below Microsoft Graph Api code:

using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

namespace AADConsole2
{
    class Program
    {

        private const string aadInstance = "https://login.microsoftonline.com/{0}";
        //  private const string ResourceUrl = "https://graph.windows.net";

        private const string resource = "https://graph.microsoft.com";
        private const string GraphServiceObjectId = "XXX";
        private const string TenantId = "XXX";
        private const string tenant = "XXXX.onmicrosoft.com";
        private const string ClientId = "XXX";
        private static string appKey= "XXXX";
        static string authority = String.Format(System.Globalization.CultureInfo.InvariantCulture, aadInstance, tenant);

        private static HttpClient httpclient = new HttpClient();
        private static AuthenticationContext context = null;
        private static ClientCredential credential = null;


        static void Main(string[] args)
        {

            context = new AuthenticationContext(authority);
            credential = new ClientCredential(ClientId, appKey);
            Task<string> token = GetToken();
            token.Wait();
            Console.WriteLine(token.Result);
            Task<string> users = GetUsers(token.Result);
            users.Wait();
            Console.WriteLine(users.Result);
            Console.ReadLine();
        }

        private static async Task<string> GetUsers(string result) {
            //throw new NotImplementedException();
            string users = null;
            var uri = "https://graph.microsoft.com/v1.0/users";
            httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", result);
            var getResult = await httpclient.GetAsync(uri);

            if(getResult.Content != null)
            {
                users = await getResult.Content.ReadAsStringAsync();

            }
            return users;

        }


        private static async Task<string> GetToken()
        {
            AuthenticationResult result = null;
            string token = null;
            result = await context.AcquireTokenAsync(resource, credential);
            token = result.AccessToken;
            return token;



        }
    }
}

我在控制臺(tái)上打印了用戶(hù)詳細(xì)信息的結(jié)果,但只打印了有限數(shù)量的用戶(hù).即只有其名稱(chēng)以字母a"開(kāi)頭.并且還缺少一些用戶(hù)詳細(xì)信息.如何獲取所有用戶(hù)詳細(xì)信息.我在這段代碼中缺少一些 api 嗎?謝謝.

I am getting the results of user detail printed on console ,but only limited number of users are printed. i.e only whose name starts with letter 'a'. And also some user details are missing. How to get all user details .Am i missing some api in this code? Thanks.

推薦答案

大多數(shù) Microsoft Graph 端點(diǎn)返回分頁(yè)結(jié)果集.您的初始請(qǐng)求僅返回第一頁(yè)數(shù)據(jù).要檢索下一頁(yè),請(qǐng)遵循 @odata.nextLink 屬性中提供的 URI.每個(gè)后續(xù)頁(yè)面將返回下一頁(yè)的 @odata.nextLink 直到您的最后一頁(yè)數(shù)據(jù)(由結(jié)果中缺少 @odata.nextLink 表示).在 在您的應(yīng)用中分頁(yè) Microsoft Graph 數(shù)據(jù).

Most Microsoft Graph endpoints return paged result sets. Your initial request only returns the first page of data. To retrieve the next page, you follow the URI provided in the @odata.nextLink property. Each subsequent page will return the next page's @odata.nextLink until you the last page of data (denoted by the lack of a @odata.nextLink in the result). There is a step-by-step walkthrough of how this works at Paging Microsoft Graph data in your app.

我可以在這里給你的最重要的一條提示是不要使用 $top 來(lái)強(qiáng)制它返回大頁(yè)數(shù)據(jù).這是一種調(diào)用 API 效率極低的方法,不可避免地會(huì)導(dǎo)致網(wǎng)絡(luò)錯(cuò)誤和請(qǐng)求限制.它也沒(méi)有消除處理分頁(yè)的需要,因?yàn)榧词?$top=999(最大值)仍然可以返回多個(gè)頁(yè)面.

The single most important tip I can give you here is to not use $top to force it to return large pages of data. This is an extremely inefficient method for calling the API and inevitably leads to network errors and request throttling. It also doesn't eliminate the need to handle paging since even $top=999 (the maximum) can still return multiple pages.

實(shí)現(xiàn)分頁(yè),保持頁(yè)面較小,并在返回每個(gè)頁(yè)面后處理結(jié)果,然后再轉(zhuǎn)到下一頁(yè).這將確保您捕獲所有數(shù)據(jù)允許您的應(yīng)用程序在處理過(guò)程中遇到任何錯(cuò)誤時(shí)從中斷的地方繼續(xù).

Implement paging, keep your page sizes small, and process the results after each page is returned before moving on to the next page. This will ensure you capture all of the data and allow your application to pick up where it left off should it encounter any errors during processing.

這篇關(guān)于C# 中的 Microsoft Graph api 代碼僅顯示有限數(shù)量的用戶(hù)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進(jìn)行身份驗(yàn)證并跨請(qǐng)求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權(quán)不起作用)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護(hù)進(jìn)程或服務(wù)器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問(wèn)令牌和刷新令牌) - IT屋-程序員軟件開(kāi)發(fā)技
.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問(wèn)令牌以與 Microsoft Graph 一起使用)
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調(diào)用時(shí) Azure KeyVault Active Directory AcquireTokenAsync 超時(shí))
Getting access token using email address and app password from oauth2/token(使用電子郵件地址和應(yīng)用程序密碼從 oauth2/token 獲取訪問(wèn)令牌)
主站蜘蛛池模板: 亚洲一区综合 | 91精品在线看 | 色婷婷影院 | 欧美精品久久久久久久久久 | 亚洲激精日韩激精欧美精品 | 91在线资源 | 国产精品高清在线 | 亚洲一区 | 成人久久久| 国外成人在线视频 | 日韩精品影院 | 中文字幕成人av | 国产情侣在线看 | www国产成人 | 日韩精品激情 | 天天综合网7799精品 | 国产成人麻豆免费观看 | 日日噜噜噜夜夜爽爽狠狠视频, | 国产日韩一区二区三免费高清 | 欧美高清性xxxxhdvideosex | 欧美日韩一区二区三区在线观看 | 一区二区免费在线观看 | 欧美综合久久久 | 夜夜摸夜夜操 | 国产二区在线播放 | 精品国产区 | 曰韩三级 | 91精品欧美久久久久久久 | 精品久久影院 | 日本黄色影片在线观看 | 天天干天天爱天天爽 | 亚洲视频一区二区三区 | 91中文字幕在线 | 久久久人成影片一区二区三区 | 欧美亚洲第一区 | 特级做a爰片毛片免费看108 | 国产区在线观看 | 日韩精品一区二区三区中文在线 | 狠狠干av| 久久日韩粉嫩一区二区三区 | 精品欧美|