Microsoft Graph API - Get directory objects from a list of ids - Bad request
I need to get a list of groups that the user is a member of using Microsoft Graph API.
For this, I am using the endpoint POST /users/<userId>/getMemberGroups
(doc). This works fine but the problem is that the response is only a list of group object ids. I need to get group properties too. I could just loop through the list and query API for GET /groups/<groupId>
but this takes too long when the user has multiple groups.
Then I found POST /directoryObjects/getById
(doc) which turns that list into what I need. I have followed the doc page exactly but I am getting the following error:
Request_BadRequest - Specified HTTP method is not allowed for the request target. (HTTP status 405)
What am I doing wrong? Is the method getById
bugged? If it is, is there any alternative way to turn a list of group object ids into groups or to get full list of user groups?
azure-active-directory microsoft-graph
add a comment |
I need to get a list of groups that the user is a member of using Microsoft Graph API.
For this, I am using the endpoint POST /users/<userId>/getMemberGroups
(doc). This works fine but the problem is that the response is only a list of group object ids. I need to get group properties too. I could just loop through the list and query API for GET /groups/<groupId>
but this takes too long when the user has multiple groups.
Then I found POST /directoryObjects/getById
(doc) which turns that list into what I need. I have followed the doc page exactly but I am getting the following error:
Request_BadRequest - Specified HTTP method is not allowed for the request target. (HTTP status 405)
What am I doing wrong? Is the method getById
bugged? If it is, is there any alternative way to turn a list of group object ids into groups or to get full list of user groups?
azure-active-directory microsoft-graph
add a comment |
I need to get a list of groups that the user is a member of using Microsoft Graph API.
For this, I am using the endpoint POST /users/<userId>/getMemberGroups
(doc). This works fine but the problem is that the response is only a list of group object ids. I need to get group properties too. I could just loop through the list and query API for GET /groups/<groupId>
but this takes too long when the user has multiple groups.
Then I found POST /directoryObjects/getById
(doc) which turns that list into what I need. I have followed the doc page exactly but I am getting the following error:
Request_BadRequest - Specified HTTP method is not allowed for the request target. (HTTP status 405)
What am I doing wrong? Is the method getById
bugged? If it is, is there any alternative way to turn a list of group object ids into groups or to get full list of user groups?
azure-active-directory microsoft-graph
I need to get a list of groups that the user is a member of using Microsoft Graph API.
For this, I am using the endpoint POST /users/<userId>/getMemberGroups
(doc). This works fine but the problem is that the response is only a list of group object ids. I need to get group properties too. I could just loop through the list and query API for GET /groups/<groupId>
but this takes too long when the user has multiple groups.
Then I found POST /directoryObjects/getById
(doc) which turns that list into what I need. I have followed the doc page exactly but I am getting the following error:
Request_BadRequest - Specified HTTP method is not allowed for the request target. (HTTP status 405)
What am I doing wrong? Is the method getById
bugged? If it is, is there any alternative way to turn a list of group object ids into groups or to get full list of user groups?
azure-active-directory microsoft-graph
azure-active-directory microsoft-graph
edited Nov 13 '18 at 16:49
Marc LaFleur
18.8k31833
18.8k31833
asked Nov 13 '18 at 5:51
bloodlehbloodleh
101115
101115
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The API Get directory objects from a list of ids
you mentioned should work, I test it in the MS Graph Explorer, it works fine.
Make sure you use POST
method, I can reproduce your issue with another method.
You could refer to the informations below and try again.
Request URL:
POST https://graph.microsoft.com/beta/directoryObjects/getByIds
Request Body:
{
"ids": [
"xxxxxxxx-9f1b-4f28-a408-xxxxxxxxxxxx",
"xxxxxxxx-a614-4335-81eb-xxxxxxxxxxxx",
"xxxxxxxx-e500-49d6-a705-xxxxxxxxxxxx",
"xxxxxxxx-5be3-41eb-864d-xxxxxxxxxxxx",
"xxxxxxxx-961d-4db9-87cf-xxxxxxxxxxxx",
"xxxxxxxx-93bf-4950-8d96-xxxxxxxxxxxx"
],
"types": [
"group"
]
}
Result:
I tried doing it in Graph Explorer yesterday using POST method and it still failed. Now I tried it again and it worked. I think the explorer might have just bugged out somehow (or I made a typo somewhere...). Thanks! :)
– bloodleh
Nov 13 '18 at 20:58
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53274627%2fmicrosoft-graph-api-get-directory-objects-from-a-list-of-ids-bad-request%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The API Get directory objects from a list of ids
you mentioned should work, I test it in the MS Graph Explorer, it works fine.
Make sure you use POST
method, I can reproduce your issue with another method.
You could refer to the informations below and try again.
Request URL:
POST https://graph.microsoft.com/beta/directoryObjects/getByIds
Request Body:
{
"ids": [
"xxxxxxxx-9f1b-4f28-a408-xxxxxxxxxxxx",
"xxxxxxxx-a614-4335-81eb-xxxxxxxxxxxx",
"xxxxxxxx-e500-49d6-a705-xxxxxxxxxxxx",
"xxxxxxxx-5be3-41eb-864d-xxxxxxxxxxxx",
"xxxxxxxx-961d-4db9-87cf-xxxxxxxxxxxx",
"xxxxxxxx-93bf-4950-8d96-xxxxxxxxxxxx"
],
"types": [
"group"
]
}
Result:
I tried doing it in Graph Explorer yesterday using POST method and it still failed. Now I tried it again and it worked. I think the explorer might have just bugged out somehow (or I made a typo somewhere...). Thanks! :)
– bloodleh
Nov 13 '18 at 20:58
add a comment |
The API Get directory objects from a list of ids
you mentioned should work, I test it in the MS Graph Explorer, it works fine.
Make sure you use POST
method, I can reproduce your issue with another method.
You could refer to the informations below and try again.
Request URL:
POST https://graph.microsoft.com/beta/directoryObjects/getByIds
Request Body:
{
"ids": [
"xxxxxxxx-9f1b-4f28-a408-xxxxxxxxxxxx",
"xxxxxxxx-a614-4335-81eb-xxxxxxxxxxxx",
"xxxxxxxx-e500-49d6-a705-xxxxxxxxxxxx",
"xxxxxxxx-5be3-41eb-864d-xxxxxxxxxxxx",
"xxxxxxxx-961d-4db9-87cf-xxxxxxxxxxxx",
"xxxxxxxx-93bf-4950-8d96-xxxxxxxxxxxx"
],
"types": [
"group"
]
}
Result:
I tried doing it in Graph Explorer yesterday using POST method and it still failed. Now I tried it again and it worked. I think the explorer might have just bugged out somehow (or I made a typo somewhere...). Thanks! :)
– bloodleh
Nov 13 '18 at 20:58
add a comment |
The API Get directory objects from a list of ids
you mentioned should work, I test it in the MS Graph Explorer, it works fine.
Make sure you use POST
method, I can reproduce your issue with another method.
You could refer to the informations below and try again.
Request URL:
POST https://graph.microsoft.com/beta/directoryObjects/getByIds
Request Body:
{
"ids": [
"xxxxxxxx-9f1b-4f28-a408-xxxxxxxxxxxx",
"xxxxxxxx-a614-4335-81eb-xxxxxxxxxxxx",
"xxxxxxxx-e500-49d6-a705-xxxxxxxxxxxx",
"xxxxxxxx-5be3-41eb-864d-xxxxxxxxxxxx",
"xxxxxxxx-961d-4db9-87cf-xxxxxxxxxxxx",
"xxxxxxxx-93bf-4950-8d96-xxxxxxxxxxxx"
],
"types": [
"group"
]
}
Result:
The API Get directory objects from a list of ids
you mentioned should work, I test it in the MS Graph Explorer, it works fine.
Make sure you use POST
method, I can reproduce your issue with another method.
You could refer to the informations below and try again.
Request URL:
POST https://graph.microsoft.com/beta/directoryObjects/getByIds
Request Body:
{
"ids": [
"xxxxxxxx-9f1b-4f28-a408-xxxxxxxxxxxx",
"xxxxxxxx-a614-4335-81eb-xxxxxxxxxxxx",
"xxxxxxxx-e500-49d6-a705-xxxxxxxxxxxx",
"xxxxxxxx-5be3-41eb-864d-xxxxxxxxxxxx",
"xxxxxxxx-961d-4db9-87cf-xxxxxxxxxxxx",
"xxxxxxxx-93bf-4950-8d96-xxxxxxxxxxxx"
],
"types": [
"group"
]
}
Result:
edited Nov 13 '18 at 7:07
answered Nov 13 '18 at 6:50
Joy WangJoy Wang
6,6682213
6,6682213
I tried doing it in Graph Explorer yesterday using POST method and it still failed. Now I tried it again and it worked. I think the explorer might have just bugged out somehow (or I made a typo somewhere...). Thanks! :)
– bloodleh
Nov 13 '18 at 20:58
add a comment |
I tried doing it in Graph Explorer yesterday using POST method and it still failed. Now I tried it again and it worked. I think the explorer might have just bugged out somehow (or I made a typo somewhere...). Thanks! :)
– bloodleh
Nov 13 '18 at 20:58
I tried doing it in Graph Explorer yesterday using POST method and it still failed. Now I tried it again and it worked. I think the explorer might have just bugged out somehow (or I made a typo somewhere...). Thanks! :)
– bloodleh
Nov 13 '18 at 20:58
I tried doing it in Graph Explorer yesterday using POST method and it still failed. Now I tried it again and it worked. I think the explorer might have just bugged out somehow (or I made a typo somewhere...). Thanks! :)
– bloodleh
Nov 13 '18 at 20:58
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53274627%2fmicrosoft-graph-api-get-directory-objects-from-a-list-of-ids-bad-request%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown