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

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

Open
antoniom opened this issue Aug 6, 2024 · 2 comments
Open
Assignees
Labels
no-recent-activity service bug status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close

Comments

@antoniom
Copy link

antoniom commented Aug 6, 2024

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_
@antoniom antoniom added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Aug 6, 2024
@antoniom antoniom changed the title Getting "Invalid enum value unknown" when not settings userPurpose Getting "Invalid enum value unknown" when trying to update mailboxSettings Aug 6, 2024
@Ndiritu Ndiritu added needs investigation and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Aug 8, 2024
@timayabi2020
Copy link

@antoniom, thank you for raising this issue. After investigations, I found out that the service is returning an undefined/undocumented value (unkown) for the property userPurpose.
image
Based on the documentation here https://learn.microsoft.com/en-us/graph/api/resources/mailboxsettings?view=graph-rest-1.0#userpurpose-values, the value unkown is not among the list of documented enums.
image
It is also not specified in the OpenAPI file used to generate this particular service in the SDK.
image

Unfortunately for API related issues/questions we are not best placed to give an answer. Kindly raise an issue here https://developer.microsoft.com/en-us/graph/support so that the API owner can respond to it.

@timayabi2020 timayabi2020 added service bug status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed needs investigation type:bug A broken experience labels Aug 20, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-recent-activity service bug status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close
Projects
None yet
Development

No branches or pull requests

3 participants