Microsoft Graph API를 실험 중이며 Microsoft 개발자 사이트에서 QuickStarts로 프로젝트를 설정합니다.Microsoft Graph에서 모든 연락처를 나열하는 방법은 무엇입니까?
기록 된 계정과 관련된 모든 이메일 주소록을 나열하려고 할 때 현재 문제가 있습니다.
내 문제는 적절한 프런트 엔드 목록을 사용하는 경우에도 NullReference
예외가 발생하므로 ViewBag
에 정보를 요청하고 전달하는 방법에 문제가있는 것으로 보입니다.
HomeController.cs
public async Task<ActionResult> GetMyContacts()
{
try
{
// Init GraphServiceClient
GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient();
var contacts = await graphService.GetMyEmailContacts(graphClient);
ViewBag.Contacts = contacts;
return View("Graph");
}
catch (ServiceException se)
{
if (se.Error.Message == Resource.Error_AuthChallengeNeeded) return new EmptyResult();
return RedirectToAction("Index", "Error", new { message = Resource.Error_Message + Request.RawUrl + ": " + se.Error.Message });
}
}
GraphService.cs
public async Task<IList<Contact>> GetMyEmailContacts(GraphServiceClient graphClient)
{
User me = await graphClient.Me.Request().Select("mail,userPrincipalName").GetAsync();
var contacts = me.Contacts;
return contacts;
}
내가 여기 실종 무엇 Graph.cshtml
<div class="col-sm-12">
<pre name="user-contacts">@ViewBag.Contacts</pre>
</div>
<h2>TEST GET CONTACTS</h2>
<div class="col-sm-12">
<p>@Html.Raw(ViewBag.Contacts)</p>
</div>
: 여기
는 관련 코드?
당신이 그래프보기에 대한 forontend 코드를 보여 주시겠습니까? – krzysztofla
@ KrzysztofLa 완료 –