msgraph-sdk-dotnet icon indicating copy to clipboard operation
msgraph-sdk-dotnet copied to clipboard

Create event - resource attendees is ignored

Open rzechu opened this issue 4 months ago • 0 comments

Describe the bug

I am using .NET SDK to create event with me as required + resource attendee Command is send and completed sucessfully. Event is created for me and resource but in scheduling assistand resource is missing

Apologize for polish language GUI, but images should be self explanatory

image

Resource is missing... (check Expected behavior)

outlook_invalid

Expected behavior

Resource should be visible in Scheduling Assistant This is how looks like event created in outlook. outlook_valid

How to reproduce

    public async Task<EventAddResultDto> EventAdd(EventAddDto eventAddDto, CancellationToken cancellationToken)
    {
        ArgumentNullException.ThrowIfNull(nameof(eventAddDto));
        ArgumentNullException.ThrowIfNull(nameof(eventAddDto.MlaUser));

        Event msGraphEvent = new()
        {
            Subject = eventAddDto.Subject,
            Body = new ItemBody
            {
                Content = eventAddDto.Body,
                ContentType = eventAddDto.IsHtmlBody ? BodyType.Html : BodyType.Text,
            },

            Start = new DateTimeTimeZone
            {
                DateTime = eventAddDto.StartUtcTime.ToString("o"),
                TimeZone = eventAddDto.StartUtcTime.ToDateTimeTimeZone().TimeZone,
            },
            End = new DateTimeTimeZone
            {
                DateTime = eventAddDto.EndUtcTime.ToString("o"),
                TimeZone = eventAddDto.EndUtcTime.ToDateTimeTimeZone().TimeZone,
            },
            Location = new Location
            {
                DisplayName = eventAddDto.Location,
            },
            Attendees = eventAddDto.Attendees.Select(s => new Attendee
            {
                EmailAddress = new EmailAddress { Address = s.EmailAddress },
                Type = s.Type.ToMsGraphType(),
            }).ToList()
        };

        _logger.Info("Adding event to MS Graph {SubjectText}={Subject}, {StartText}={Start} {EndText}={End}",
            nameof(msGraphEvent.Subject), msGraphEvent.Subject, nameof(msGraphEvent.Start), msGraphEvent.Start, nameof(msGraphEvent.End), msGraphEvent.End);
        _logger.Info("Adding event to MS Graph Attendees={Attendees}", msGraphEvent.Attendees);

        msGraphEvent.AllowNewTimeProposals = false;
        msGraphEvent.OnlineMeetingProvider = OnlineMeetingProviderType.TeamsForBusiness;
        msGraphEvent.IsOnlineMeeting = eventAddDto.IsOnlineMeeting;

        var eventResult = await _msClient.Users[eventAddDto.MlaUser].Events.PostAsync(msGraphEvent, null, cancellationToken);
        if (eventResult is null)
            throw new Exception("Event was not added");

        var eventAddResult = new EventAddResultDto()
        {
            Id = eventResult.Id,
            ICalUId = eventResult.ICalUId,
            WebLink = eventResult.WebLink,
        };

        return eventAddResult!;
    }

SDK Version

5.40.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

- Windows 11 x64

### Other information

_No response_

rzechu avatar Oct 11 '24 08:10 rzechu