Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during request or responce with error when creating recurring CalendarItem event #616

Open
ValerianMemsk opened this issue Feb 15, 2023 · 0 comments

Comments

@ValerianMemsk
Copy link

ValerianMemsk commented Feb 15, 2023

Version (e.g. 1.0, dev-master):
PHP version: 8.1
Microsoft Exchange version: 2013 (if i assume correctly)

Description of problem:
Trying to create CalendarItem event in exchange calendar with user-provided data.
Simple ones and with partisipants working fine. But when I try to add recurrence in those events - nothing works. Watched similar questions here and on stackoverflow - they seem outdated. Tried to implement them with v1.0 classes - didnt work
What am I doing wrong?

Example request:

Tried daily and weekly recurrence.

    $request = new CreateItemType();
    $request->Items = new NonEmptyArrayOfAllItemsType();

    //Event accembly---------------------------
    $event = new CalendarItemType();

    $event->Start = $eventData['startTime'];
    $event->End = $eventData['endTime'];
    $event->Subject = $eventData['subject'];
    $event->Location = $eventData['location'];

    //In case event is recurring---------------
    if ($eventData['isRecurring']) {
      $event->CalendarItemType = CalendarItemTypeType::RECURRING_MASTER;
      $recurrence = new RecurrenceType();

      switch ($eventData['recurrenceDetails']['type']) {
        case 'daily':
          $recurrence->DailyRecurrence = new DailyRecurrencePatternType();
          $event->Recurrence = $recurrence;
          break;

        case 'weekly':

          $weeklyRecurrenceInfo = new WeeklyRecurrencePatternType();
          $weeklyRecurrenceInfo->Interval = $eventData['recurrenceDetails']['interval'];
          $weeklyRecurrenceInfo->DaysOfWeek = new ArrayOfStringsType();
          $weeklyRecurrenceInfo->DaysOfWeek = [DayOfWeekType::THURSDAY];

          $recurrence->WeeklyRecurrence = $weeklyRecurrenceInfo;
          $event->Recurrence = $recurrence;
          break;
      }
    }  
    
    $eventBody = new BodyType();
    $eventBody->_ = $eventData['description'];
    $eventBody->BodyType = BodyTypeType::TEXT;

    $event->Body = $eventBody;
    
    $request->Items->CalendarItem[] = $event;
    //--------------------------------------------

    $request->SendMeetingInvitations = CalendarItemCreateOrDeleteOperationType::SEND_TO_NONE;

    $response = $this->client->CreateItem($request);
    return $response;    

Example response:

Daily option leads to

local.ERROR: The request is invalid. {"userId":11,"exception":"[object] (SoapFault(code: 0 faultcode: a:ErrorInvalidRequest detail: {\"ResponseCode\":\"ErrorInvalidRequest\",\"Message\":\"The request is invalid.\"}): The request is invalid. at /var/www/html/vendor/php-ews/php-ews/src/Client.php:1631)

Weekly to response with:

+CreateItemResponseMessage: array:1 [▼
      0 => jamesiarmes\PhpEws\Response\ItemInfoResponseMessageType {#2516 ▼
        +DescriptiveLinkKey: 0
        +MessageText: "Set action is invalid for property."
        +MessageXml: {#2495 ▼
          +"any": array:1 [▼
            "FieldURI" => jamesiarmes\PhpEws\Type\PathToUnindexedFieldType {#2493 ▼
              +FieldURI: "calendar:CalendarItemType"
            }
          ]
        }
        +ResponseClass: "Error"
        +ResponseCode: "ErrorInvalidPropertySet"
        +Items: jamesiarmes\PhpEws\ArrayType\ArrayOfRealItemsType {#2517 ▶}
      }
    ]

Additional details:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant