microsoftgraph / microsoftgraph/msgraph-sdk-java
expand of appRoleAssignments on user get call yields no results
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 444
- Forks
- 154
- Avg merge
- 18h 28m
- Merged PRs (30d)
- 4
Description
Describe the bug
I was trying to get a user together with it's appRoleAssignments in one call. The documentation is pointing out that the expand feature for appRoleAssignments is supported. But it doesn't work.
Expected behavior
I would expect the expand to return results.
How to reproduce
User user = graphClient.usersWithUserPrincipalName(username).get(
rc -> {
rc.queryParameters.select = new String[]{"id", "userPrincipalName", "displayName", "givenName", "surname", "accountEnabled"};
rc.queryParameters.expand = new String[]{"appRoleAssignments"};
}
);
or
graphClient.users().byUserId(username).get(
rc -> {
rc.queryParameters.select = new String[]{"id", "userPrincipalName", "displayName", "givenName", "surname", "accountEnabled"};
rc.queryParameters.expand = new String[]{"appRoleAssignments"};
}
);
SDK Version
6.22.0
Latest version known to work for scenario above?
No response
Known Workarounds
For now I have to write this code to get it done:
var user = graphClient.usersWithUserPrincipalName(username).get(
rc -> rc.queryParameters.select = new String[]{"id", "userPrincipalName", "displayName", "givenName", "surname", "accountEnabled"}
);
user.setAppRoleAssignments(getAllAppRoleAssignments(user.getId())); // an 'expand' of appRoleAssignments in the above call gave an empty array :| ...
return user;
private List<AppRoleAssignment> getAllAppRoleAssignments(String userId) {
var result = new ArrayList<AppRoleAssignment>();
var page = graphClient.users().byUserId(userId).appRoleAssignments().get();
while (page != null) {
result.addAll(Optional.ofNullable(page.getValue()).orElse(emptyList()));
var odataNextLink = page.getOdataNextLink();
if (StringUtils.isBlank(odataNextLink)) {
break;
} else {
page = graphClient.users().byUserId(userId).appRoleAssignments().withUrl(odataNextLink).get();
}
}
return result;
}
Debug output
Click to expand log
```</details>
### Configuration
_No response_
### Other information
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two user GET calls in the issue with the appRoleAssignments expand and compare their responses with the separate appRoleAssignments request. Check whether the documented expand behavior is supported by the Graph service and SDK version 6.22.0; done means the combined request returns the expected assignments or the limitation is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100