microsoftgraph / microsoftgraph/msgraph-sdk-php

Getting "Invalid enum value unknown" when trying to update mailboxSettings

Open
#1,565 3 comments 0 reactions 1 assignee View on GitHub

@timayabi2020 is already working on this.

Since Aug 8, 2024.

no-recent-activity service bug status:waiting-for-author-feedback
Dominant language
PHP
Stars
669
Forks
150
Avg merge
15h 21m
Merged PRs (30d)
3

Description

Describe the bug

I am trying to update the mailboxSettings of a user via the following script

$mailboxSettings = new MailboxSettings();

$automaticRepliesSetting = new AutomaticRepliesSetting();
$automaticRepliesSetting->setStatus(new AutomaticRepliesStatus(AutomaticRepliesStatus::DISABLED));
$automaticRepliesSetting->setExternalAudience(new ExternalAudienceScope(ExternalAudienceScope::ALL));
$automaticRepliesSetting->setExternalReplyMessage("I am out of office with limited access to email.");
$automaticRepliesSetting->setInternalReplyMessage("I am out of office with limited access to email.");
$mailboxSettings->setAutomaticRepliesSetting($automaticRepliesSetting);

$response = $msGraph
    ->getClient()
    ->users()
    ->byUserId(<USERID>)
    ->mailboxSettings()
    ->patch($mailboxSettings)
    ->wait();

And I receive the following exception

Exception 'InvalidArgumentException' with message 'Invalid enum value unknown'

in /var/www/html/vendor/microsoft/kiota-abstractions/src/Enum.php:57

Stack trace:
#0 /var/www/html/vendor/microsoft/kiota-serialization-json/src/JsonParseNode.php(164): Microsoft\Kiota\Abstractions\Enum->__construct('unknown')
#1 /var/www/html/vendor/microsoft/microsoft-graph/src/Generated/Models/MailboxSettings.php(121): Microsoft\Kiota\Serialization\Json\JsonParseNode->getEnumValue('Microsoft\\Graph...')
#2 /var/www/html/vendor/microsoft/kiota-serialization-json/src/JsonParseNode.php(141): Microsoft\Graph\Generated\Models\MailboxSettings->Microsoft\Graph\Generated\Models\{closure}(Object(Microsoft\Kiota\Serialization\Json\JsonParseNode))
#3 /var/www/html/vendor/microsoft/kiota-serialization-json/src/JsonParseNode.php(114): Microsoft\Kiota\Serialization\Json\JsonParseNode->assignFieldValues(Object(Microsoft\Graph\Generated\Models\MailboxSettings))
#4 /var/www/html/vendor/microsoft/kiota-http-guzzle/src/GuzzleRequestAdapter.php(170): Microsoft\Kiota\Serialization\Json\JsonParseNode->getObjectValue(Array)
#5 /var/www/html/vendor/php-http/promise/src/FulfilledPromise.php(39): Microsoft\Kiota\Http\GuzzleRequestAdapter->Microsoft\Kiota\Http\{closure}(Object(GuzzleHttp\Psr7\Response))
#6 /var/www/html/vendor/microsoft/kiota-http-guzzle/src/GuzzleRequestAdapter.php(145): Http\Promise\FulfilledPromise->then(Object(Closure))
#7 /var/www/html/vendor/microsoft/microsoft-graph/src/Generated/Users/Item/MailboxSettings/MailboxSettingsRequestBuilder.php(59): Microsoft\Kiota\Http\GuzzleRequestAdapter->sendAsync(Object(Microsoft\Kiota\Abstractions\RequestInformation), Array, Array)
#8 /var/www/html/commands/OutOfOfficeController.php(99): Microsoft\Graph\Generated\Users\Item\MailboxSettings\MailboxSettingsRequestBuilder->patch(Object(Microsoft\Graph\Generated\Models\MailboxSettings))

MailboxSettings.php(121) -> points to UserPurpose which is a readonly value and shouldn't be set.

If a try to set it
e.g.

$mailboxSettings->setUserPurpose(new UserPurpose(UserPurpose::ROOM));

I get the error, the property 'userPurpose' was specified but is not supported with this request.

Expected behavior

The request to succeed without having to call setSserPurpose property

How to reproduce

Execute the above script

SDK Version

2.12.0

Latest version known to work for scenario above?

No response

Known Workarounds

Use msgraph-sdk-php-core and execute the request manually ie

$httpClient = GraphClientFactory::createWithConfig($config);
$response = $httpClient->patch(
    '/v1.0/users/<USER-ID>/mailboxSettings',
    [
        'json' => [
            'automaticRepliesSetting' => [
                "externalAudience"=> "all",
                "status" => "disabled"
            ]
        ]
    ]
);
Debug output
Click to expand log ```
</details>


### Configuration

PHP 8.3

### Other information

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.