Microsoft Graph Java SDK v.6.16.0 return empty site list with "*" and ""(empty) search query parameter
Describe the bug
Create GraphServiceClient with UsernamePasswordCredential provider
var provider = new UsernamePasswordCredentialBuilder()
.clientId("client_id")
.username("username")
.password("password");
var graphClient = new GraphServiceClient(provider);
Call graphClient.sites().get().getValue()
Expected result: receive a list of the sites Actual result: an empty list was returned without any error.
GraphServiceClient with ClientSecretCredential provider works as expected on graphClient.sites().get().getValue() call.
SDK Version
6.16.0
Make some additional queries:
- Search query like
"*":
graphServiceClient.sites()
.get(requestConfiguration -> {
var queryParameters = requestConfiguration.queryParameters;
queryParameters.select = new String[]{SELECT_SITE_NAME};
queryParameters.search = "*";
})
.getValue()
Expected: get list of sites
Actual result: com.microsoft.graph.models.odataerrors.ODataError: Syntax error: character '*' is not valid at position 0 in '*'.
- Search query empty
"":
graphServiceClient.sites()
.get(requestConfiguration -> {
var queryParameters = requestConfiguration.queryParameters;
queryParameters.select = new String[]{SELECT_SITE_NAME};
queryParameters.search = "";
})
.getValue()
Expected: get list of sites
Actual result: com.microsoft.graph.models.odataerrors.ODataError: Expression expected at position 0 in ''.
- Search query like
"all":
graphServiceClient.sites()
.get(requestConfiguration -> {
var queryParameters = requestConfiguration.queryParameters;
queryParameters.select = new String[]{SELECT_SITE_NAME};
queryParameters.search = "all";
})
.getValue()
Expected: get list of sites Actual result: got 3 sites instead 99
Java SDK v5.80.0 request with same client_id and user:
graphServiceClient
.sites()
.buildRequest(new QueryOption("search", "*"), new QueryOption("select", "id,name"))
.get()
.getCurrentPage()
Expected: get list of sites Actual result: got 99 sites
Work solution: https://github.com/microsoftgraph/msgraph-sdk-java/issues/2090#issuecomment-2390888773
Please tell me, will this bug be fixed in the next SDK releases?
@SashaUsov this will need to be prioritized against other issues. For now, it's likely that it won't make it into the next release. I'm also unable to reproduce the behaviour and would need further investigation here.
In the meantime, using withUrl() should help until this is resolved.