msgraph-sdk-java icon indicating copy to clipboard operation
msgraph-sdk-java copied to clipboard

com.microsoft.graph.models.odataerrors.ODataError exception when trying to create Subscription

Open loudbyte opened this issue 7 months ago • 1 comments

Describe the bug

In our java springboot app we use the following dependency: https://mvnrepository.com/artifact/com.microsoft.graph/microsoft-graph/5.72.0 (also checked on https://mvnrepository.com/artifact/com.microsoft.graph/microsoft-graph/6.42.1)

When we try to create eventhub subscription for meeting room via that API we are getting error:

com.microsoft.graph.http.GraphServiceException: Error code: ExtensionError\nError message: Operation: Create; Exception: [Status Code: BadRequest; Reason: The value 'https://outlook.office365.com/api/v2.0/Users('Room_Sandbox%40company.com')/Events'of parameter 'Resource' is invalid.]\n\nPOST[https://graph.microsoft.com/v1.0/subscriptions\nSdkVersion] : graph-java/v5.72.0\nSdkVersion : graph-java/v5.72.0\n[...]\n\n400 : \n[...]\n\n[Some information was truncated for brevity, enable debug logging for more details]

Room_Sandbox%40company.com - I changed this here intentionally, in the original response there is a different email.

But the error is only for particular emails, not for all. Other emails work fine.

We've tried to update to the newest dependencies related to this api but till getting the same error.

Stack trace:

com.microsoft.graph.models.odataerrors.ODataError: Operation: Create; Exception: [Status Code: BadRequest; Reason: The value 'https://outlook.office365.com/api/v2.0/Users('Room_Sandbox%40company.com')/Events' of parameter 'Resource' is invalid.] at com.microsoft.graph.models.odataerrors.ODataError.createFromDiscriminatorValue(ODataError.java:36) at com.microsoft.kiota.serialization.JsonParseNode.getObjectValue(JsonParseNode.java:212) at com.microsoft.kiota.http.OkHttpRequestAdapter.lambda$throwIfFailedResponse$0(OkHttpRequestAdapter.java:704) at com.microsoft.kiota.ApiExceptionBuilder.<init>(ApiExceptionBuilder.java:26) at com.microsoft.kiota.http.OkHttpRequestAdapter.throwIfFailedResponse(OkHttpRequestAdapter.java:703) at com.microsoft.kiota.http.OkHttpRequestAdapter.send(OkHttpRequestAdapter.java:307) at com.microsoft.graph.subscriptions.SubscriptionsRequestBuilder.post(SubscriptionsRequestBuilder.java:100) at com.microsoft.graph.subscriptions.SubscriptionsRequestBuilder.post(SubscriptionsRequestBuilder.java:84)

Expected behavior

The subscription should be created without errors.

How to reproduce

Try to create subscription for meeting room

SDK Version

6.42.1

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

loudbyte avatar Jul 01 '25 16:07 loudbyte

The issue was related to the permissions of rooms and the service account that is used in the MS Graph API. However, the error message is confusing because it refers to invalid parameters and "ErrorItemNotFound." It would be better to receive a message about permission issues.

loudbyte avatar Jul 03 '25 16:07 loudbyte