question

CarlOgden-7135 avatar image
0 Votes"
CarlOgden-7135 asked ShwetaChoudhary-8869 edited

Creating a calendar event - location information ignored

Hi

I've got the following code, which creates an appointment from our web based system in Outlook Calendar. But, the location just shows the address as text and not as a configured location. Can someone help in what I've done wrong?

                         $app_location = [
                             'displayName'  => $location,
                             'locationType' => 'Default',
                             'address' => [
                                 'street'          => $property->AddressLn1,
                                 'city'            => $property->AddressLn2,
                                 'state'           => $property->AddressTown,
                                 'countryOrRegion' => $property->AddressCounty,
                                 'postalCode'      => $property->PostCode,
                             ],
                             'coordinates' => [
                                 'latitude'    => $property->Latitude,
                                 'longitude'    => $property->Longitude,
                             ]
                         ];
                         $locations = [
                             'displayName'    => $location,
                             'address' => [
                                 'street'          => $property->AddressLn1,
                                 'city'            => $property->AddressLn2,
                                 'state'           => $property->AddressTown,
                                 'countryOrRegion' => $property->AddressCounty,
                                 'postalCode'      => $property->PostCode,
                             ],
                             'coordinates' => [
                                 'latitude'    => $property->Latitude,
                                 'longitude'    => $property->Longitude,
                             ],
                         ];
                         $newEvent = [
                             'subject'                    => $event_subject,
                             'isReminderOn'               => $isReminderOn,
                             'reminderMinutesBeforeStart' => $reminderMinutesBeforeStart,
                             'isAllDay'                   => $isAllDay,
                             'showAs'                     => $showAs,
                             'sensitivity'                 => $sensitivity,
                             'body'                          => [
                                 'content' => $notes,
                                 'contentType' => 'text'
                             ],
                             'start' => [
                                 'dateTime' => $app_start_date,
                                 'timeZone' => $viewData['userTimeZone']
                             ],
                             'end' => [
                                 'dateTime' => $app_end_date,
                                 'timeZone' => $viewData['userTimeZone']
                             ],
                             'attendees'     => $attendees,
                             'location'        => [$app_location],
                             'locations'        => [$locations],
                             'transactionId' => $appointment_id,
                         ];

Thanks for any help in advance.
Carl.

microsoft-graph-calendar
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ShwetaChoudhary-8869 avatar image
0 Votes"
ShwetaChoudhary-8869 answered ShwetaChoudhary-8869 edited

Thank you for reaching out.

If you're organizing an event that involves a meeting location:

Set the location property of the event accordingly.
Set the optional locationEmailAddress property if the meeting location has an email address.
Additionally, if the meeting location has been set up as a resource, or if the event involves some equipment that has been set up as a resource:

Invite the resource as an attendee.
Set the attendee type property as resource.
Set the attendee emailAddress as the resource email address.

Sample code for creating an event that occurs in multiple locations (Javascript)


  const options = {
      authProvider,
     };
        
     const client = Client.init(options);
        
     const event = {
       subject: 'Plan summer company picnic',
       body: {
         contentType: 'HTML',
         content: 'Let\'s kick-start this event planning!'
       },
       start: {
           dateTime: '2017-08-30T11:00:00',
           timeZone: 'Pacific Standard Time'
       },
       end: {
           dateTime: '2017-08-30T12:00:00',
           timeZone: 'Pacific Standard Time'
       },
       attendees: [
         {
           emailAddress: {
             address: 'DanaS@contoso.onmicrosoft.com',
             name: 'Dana Swope'
           },
           type: 'Required'
         },
         {
           emailAddress: {
             address: 'AlexW@contoso.onmicrosoft.com',
             name: 'Alex Wilber'
           },
           type: 'Required'
         }
       ],
       location: {
         displayName: 'Conf Room 3; Fourth Coffee; Home Office',
         locationType: 'Default'
       },
       locations: [
         {
           displayName: 'Conf Room 3'
         },
         {
           displayName: 'Fourth Coffee',
           address: {
             street: '4567 Main St',
             city: 'Redmond',
             state: 'WA',
             countryOrRegion: 'US',
             postalCode: '32008'
           },
           coordinates: {
             latitude: 47.672,
             longitude: -102.103
           }
         },
         {
           displayName: 'Home Office'
         }
       ],
       allowNewTimeProposals: true
     };
        
     await client.api('/me/events')
      .post(event);

Thanks



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.