Share via

UnknownError issue with when querying communications/calls/{id}

Puneeth Umesh Bharadwaj 2 Reputation points
2022-09-01T08:12:53.697+00:00

I am using the following code to query the Graph API to retrieve a Team's call information. However, I constantly get the error (pasted below). I am not sure what I am missing. Any help is much appreciated.

Code:

// The client credentials flow requires that you request the  
// /.default scope, and preconfigure your permissions on the  
// app registration in Azure. An administrator must grant consent  
// to those permissions beforehand.  
string[] scopes = new[] { "https://graph.microsoft.com/.default" };  
  
// Multi-tenant apps can use "common",  
// single-tenant apps must use the tenant ID from the Azure portal  
//string tenantId = "common";  
string tenantId = AzureDetails.TenantID;  
  
// Values from app registration  
string clientId = AzureDetails.ClientID;  
string clientSecret = AzureDetails.ClientSecret;  
  
// using Azure.Identity;  
TokenCredentialOptions options = new()  
{  
    AuthorityHost = AzureAuthorityHosts.AzurePublicCloud  
};  
  
// https://learn.microsoft.com/dotnet/api/azure.identity.clientsecretcredential  
ClientSecretCredential clientSecretCredential = new(tenantId, clientId, clientSecret, options);  
  
GraphServiceClient graphClient = new(clientSecretCredential, scopes);  
  
call = await graphClient.Communications.Calls[id].Request().GetAsync();  

Exception:

Code: UnknownError  
Inner error:  
	AdditionalData:  
	date: 2022-08-30T17:11:46  
	request-id: b00e1f14-82d7-459b-bbdc-ae13ae04cdb2  
	client-request-id: b00e1f14-82d7-459b-bbdc-ae13ae04cdb2  
ClientRequestId: b00e1f14-82d7-459b-bbdc-ae13ae04cdb2  
  
Microsoft Security | Microsoft Graph

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 46,456 Reputation points
    2022-09-01T09:04:52.713+00:00

    Hi @Puneeth Umesh Bharadwaj

    Try my code:

    using Azure.Identity;  
    using Microsoft.Graph;  
    using Newtonsoft.Json;  
      
      
    var scopes = new[] { "https://graph.microsoft.com/.default" };  
      
    // Multi-tenant apps can use "common",  
    // single-tenant apps must use the tenant ID from the Azure portal  
    var tenantId = "{tenant id}";  
      
    // Values from app registration  
    var clientId = "{client id}";  
    var clientSecret = "{client secret}";  
      
    // using Azure.Identity;  
    var options = new TokenCredentialOptions  
    {  
        AuthorityHost = AzureAuthorityHosts.AzurePublicCloud  
    };  
      
    // https://learn.microsoft.com/dotnet/api/azure.identity.clientsecretcredential  
    var clientSecretCredential = new ClientSecretCredential(  
        tenantId, clientId, clientSecret, options);  
      
    var graphClient = new GraphServiceClient(clientSecretCredential, scopes);  
      
    var devices = await graphClient.Devices  
        .Request()  
        .GetAsync();  
      
    var call = await graphClient.Communications.Calls["{call-id}"]  
        .Request()  
        .GetAsync();  
      
    Console.WriteLine("call:" + JsonConvert.SerializeObject(call));  
    

    Also, don't forget to replace all variables in "{}" with real values.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.