Make a voice call between Teams users using Microsoft Graph API

62 Views Asked by At

Good morning guy.

I'm trying to create a voice call between two Teams users, just like Teams do.

This is the code I have.

var requestBody = new Call
{
    OdataType = "#microsoft.graph.call",
    CallbackUri = "https://bot.contoso.com/callback",
    Targets = new List<InvitationParticipantInfo>
    {
        new InvitationParticipantInfo
        {
            OdataType = "#microsoft.graph.invitationParticipantInfo",
            Identity = new IdentitySet
            {
                OdataType = "#microsoft.graph.identitySet",
                User = new Identity
                {
                    OdataType = "#microsoft.graph.identity",
                    DisplayName = response.DisplayName,
                    Id = response.Id,
                },
            },
        },
    },
    RequestedModalities = new List<Modality?>
    {
        Modality.Audio,
    },
    CallOptions = new OutgoingCallOptions
    {
        OdataType = "#microsoft.graph.outgoingCallOptions",
        IsContentSharingNotificationEnabled = true,
    },
    MediaConfig = new ServiceHostedMediaConfig
    {
        OdataType = "#microsoft.graph.serviceHostedMediaConfig",
    },
};
var result = await graphClient.Communications.Calls.PostAsync(requestBody);

response is the object of the user I'm trying to call.

When I run this code, I got a Internal Server Error in the las sentence.

var result = await graphClient.Communications.Calls.PostAsync(requestBody);

The graphClient is good, I can create any other queries with it.

This are the permissions in my Azure APP

enter image description here

What I'm missing guys.

0

There are 0 best solutions below