Hi,
I have an Admin account in Office365 with full access permission on my rooms.
I'm trying to update an event but I have a generic error "An internal server error occurred. The operation failed., Object reference not set to an instance of an object."
Following my code:
foreach ($event_updates as $update) {
// Build out item change request.
$change = new ItemChangeType();
$change->ItemId = new ItemIdType();
$change->ItemId->Id = $update['id'];
$change->ItemId->ChangeKey = $update['changekey'];
$change->Updates = new NonEmptyArrayOfItemChangeDescriptionsType();
// Set the updated subject.
$field = new SetItemFieldType();
$field->FieldURI = new PathToUnindexedFieldType();
$field->FieldURI->FieldURI = UnindexedFieldURIType::ITEM_SUBJECT;
$field->CalendarItem = new CalendarItemType();
$field->CalendarItem->Subject = $update['subject'];
$change->Updates->SetItemField[] = $field;
// Set the updated body.
$field = new SetItemFieldType();
$field->FieldURI = new PathToUnindexedFieldType();
$field->FieldURI->FieldURI = new UnindexedFieldURIType();
$field->FieldURI->FieldURI->_ = UnindexedFieldURIType::ITEM_BODY;
$field->CalendarItem = new CalendarItemType();
$field->CalendarItem->Body = new BodyType();
$field->CalendarItem->Body->_ = $update['description'];
$field->CalendarItem->Body->BodyType = BodyTypeType::TEXT;
$change->Updates->SetItemField[] = $field;
// Set the updated start time.
$field = new SetItemFieldType();
$field->FieldURI = new PathToUnindexedFieldType();
$field->FieldURI->FieldURI = UnindexedFieldURIType::CALENDAR_START;
$field->CalendarItem = new CalendarItemType();
$field->CalendarItem->Start = $update['start']->format('c');
$change->Updates->SetItemField[] = $field;
// Set the updated end time.
$field = new SetItemFieldType();
$field->FieldURI = new PathToUnindexedFieldType();
$field->FieldURI->FieldURI = UnindexedFieldURIType::CALENDAR_END;
$field->CalendarItem = new CalendarItemType();
$field->CalendarItem->End = $update['end']->format('c');
$change->Updates->SetItemField[] = $field;
$field = new SetItemFieldType();
$field->FieldURI = new PathToUnindexedFieldType();
$field->FieldURI->FieldURI = UnindexedFieldURIType::CALENDAR_RESOURCES;
$room = new AttendeeType();
$room->Mailbox = new EmailAddressType();
$room->Mailbox->EmailAddress = "myroomemailaddress";
$room->Mailbox->Name = "Room 2";
$room->Mailbox->RoutingType = RoutingType::SMTP;
$field->CalendarItem->Resources->Attendee[] = $room;
$change->Updates->SetItemField[] = $field;
//update attendees
$field = new SetItemFieldType();
$field->FieldURI = new PathToUnindexedFieldType();
$field->FieldURI->FieldURI = UnindexedFieldURIType::CALENDAR_REQUIRED_ATTENDEES;
foreach ($update['attendees'] as $guest) {
$attendee = new AttendeeType();
$attendee->Mailbox = new EmailAddressType();
$attendee->Mailbox->EmailAddress = $guest;
$attendee->Mailbox->RoutingType = RoutingType::SMTP;
$field->CalendarItem->RequiredAttendees->Attendee[] = $attendee;
}
$change->Updates->SetItemField[] = $field;
$request->ItemChanges[] = $change;
}
$response = $client->UpdateItem($request);
$response_events = array();
$response_messages = $response->ResponseMessages->UpdateItemResponseMessage;
foreach ($response_messages as $response_message) {
// Make sure the request succeeded.
if ($response_message->ResponseClass != ResponseClassType::SUCCESS) {
$code = $response_message->ResponseCode;
$message = $response_message->MessageText;
dump("Failed to update event with \"$code: $message\"\n");
return $message;
}
// Iterate over the updated events, printing the id of each.
foreach ($response_message->Items->CalendarItem as $item) {
array_push($response_events, array(
"Id" => $item->ItemId->Id,
"ChangeKey" => $item->ItemId->ChangeKey
));
}
}
return $response_events;
How can I better understand what is missing in my request?
Hi, I have an Admin account in Office365 with full access permission on my rooms. I'm trying to update an event but I have a generic error "An internal server error occurred. The operation failed., Object reference not set to an instance of an object."
Following my code: foreach ($event_updates as $update) { // Build out item change request. $change = new ItemChangeType(); $change->ItemId = new ItemIdType(); $change->ItemId->Id = $update['id']; $change->ItemId->ChangeKey = $update['changekey']; $change->Updates = new NonEmptyArrayOfItemChangeDescriptionsType();
How can I better understand what is missing in my request?
Thanks for your support