ARTICLE AD BOX
I am trying to add an event into shared calendar using MS Graph API.
I get an error when calling the Add function:
Id = 1099, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}
Here is my code:
protected void btnAdd_Click(object sender, EventArgs e) { try { var t = Add(); Response.Write(t); } catch (Exception ex) { clsCommon.LogError(ex); } } private async Task<Event> Add() { var scopes = new[] { "Calendars.ReadWrite" }; // Fixed scope var tenantId = "tenantId"; var clientId = "clientId "; var options = new DeviceCodeCredentialOptions { AuthorityHost = AzureAuthorityHosts.AzurePublicCloud, ClientId = clientId, TenantId = tenantId, DeviceCodeCallback = (code, cancellation) => { Console.WriteLine(code.Message); return Task.FromResult(0); }, }; var deviceCodeCredential = new DeviceCodeCredential(options); var graphClient = new GraphServiceClient(deviceCodeCredential, scopes); var myEvent = new Event(); myEvent.Subject = "Test"; myEvent.Body = new ItemBody() { ContentType = BodyType.Text, Content = "This is test." }; myEvent.Start = new DateTimeTimeZone() { DateTime = "2026-3-29T12:00:00", TimeZone = "Pacific Standard Time" }; myEvent.End = new DateTimeTimeZone() { DateTime = "2026-3-29T13:00:00", TimeZone = "Pacific Standard Time" }; myEvent.Location = new Location() { DisplayName = "TESTLoc" }; // Create the event. //graphClient.Me.Calendar.Events.Request().AddAsync(myEvent) var mySyncdEvent = await graphClient.Users["[email protected]"].Calendar.Events.Request().AddAsync(myEvent); return mySyncdEvent; }If I convert my button click as async and wait for the task to finish then it just gets stuck, and doesn't do anything?
I am not sure what is the right approach to handle this.
Can someone please guide me in the correct direction?
To use client ID and tenant ID to connect to shared calendar, do we need to do any setup changes in Azure Portal ?
