Skip to content

Serialization of TimeOfDay in update mailboxSettings.workingHours.startTime #217

@steffen-harbich-cognitum

Description

Greetings! I tried to update the user mailboxSetting.workingHours.startTime but ended up with an error. See also microsoftgraph/msgraph-sdk-java#168 (comment).

Code:

GraphServiceClient<Request> client = connector.getGraphClient();
        MailboxSettings mailboxSettings = new MailboxSettings();
        mailboxSettings.workingHours = new WorkingHours();
        mailboxSettings.workingHours.startTime = TimeOfDay.parse("08:30:00");

        client.customRequest("/users/6947272f-1908-49d2-b610-55418494e15f/mailboxSettings", MailboxSettings.class)
                .buildRequest()
                .patch(mailboxSettings);

Expected behavior

The update should be working as the mailboxSettings in general can be updated (other fields update successful).
See also: https://docs.microsoft.com/en-us/graph/api/resources/workinghours?view=graph-rest-1.0

Actual behavior

Error occurs:

Exception in thread "main" com.microsoft.graph.http.GraphServiceException: Error code: RequestBodyRead
Error message: An unexpected 'StartObject' node was found for property named 'startTime' when reading from the JSON reader. A 'PrimitiveValue' node was expected.

PATCH https://graph.microsoft.com/v1.0/users/6947272f-1908-49d2-b610-55418494e15f/mailboxSettings
SdkVersion : graph-java/v3.5.0
[...]

400 : Bad Request
[...]

[Some information was truncated for brevity, enable debug logging for more details]
	at com.microsoft.graph.http.GraphServiceException.createFromResponse(GraphServiceException.java:419)
	at com.microsoft.graph.http.GraphServiceException.createFromResponse(GraphServiceException.java:378)
	at com.microsoft.graph.http.CoreHttpProvider.handleErrorResponse(CoreHttpProvider.java:503)
	at com.microsoft.graph.http.CoreHttpProvider.processResponse(CoreHttpProvider.java:432)
	at com.microsoft.graph.http.CoreHttpProvider.sendRequestInternal(CoreHttpProvider.java:398)
	at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:220)
	at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:197)
	at com.microsoft.graph.http.BaseRequest.send(BaseRequest.java:332)
	at com.microsoft.graph.http.CustomRequest.patch(CustomRequest.java:129)
...

Steps to reproduce the behavior

Sdk version: 3.5
Java version: 8

Call above code on ms dev program tenant with an existing user that has assigned a license.

Additional information

The issue seems to be connected to microsoftgraph/msgraph-sdk-java#168. The TimeOfDay serializer is probably still missing in GsonFactory. The sdk is probably serializing the TimeOfDay as json object instead of string.
AB#9658

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfixed

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions