Share via

Create custom Outlook event parameters

Antonio Letizia 0 Reputation points
2023-09-08T14:18:25.09+00:00

Hi,
I contact you because, I’m developing a webpart with React on sharepoint, where I need to send custom parameters to a specific event in Outlook.Here is my function

const changeTypeEvents = async (data: any) => {
    const customData = {
      property1: "Value 1",
      property2: "Value 2",
      property3: 42,
    };
  
    const extensionName = "Com.Contoso.TypeMeetings";
    const extensionValue = {
      companyName: "Your Company",
      expirationDate: "2023-12-31T23:59:59Z",
      customProperty: customData,
    };
  
    const updateEventUrl = `https://graph.microsoft.com/v1.0/me/events/${data.id}/extensions`;
  
    try {
      const response = await fetch(updateEventUrl, {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'Authorization': `Bearer ${accessToken}`,
        },
        body: JSON.stringify({
          "@odata.type": "microsoft.graph.openTypeExtension",
          "extensionName": extensionName,
          ...extensionValue,
        }),
      });
  
      if (response.ok) {
        console.log('ok');
      } else {
        console.error('error');
      }
    } catch (error) {
      console.error('error API: ', error);
    }
  };

Here is the error:

body: (…)

  1. bodyUsed: false
  2. headers: Headers {}
  3. ok: false
  4. redirected: false
  5. status: 500
  6. statusText: "Internal Server Error"

type: "cors"

We also tried to create an extension but it has always been a mistake. You can give us some information about it. Thank you!

Microsoft 365 and Office | Development | Other
Outlook | Windows | Classic Outlook for Windows | For business
Developer technologies | .NET | Other
0 comments No comments

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.