need help in MS graph API - sharepoint sites filtered by createdUser

Casepoint Developer 66 Reputation points
2022-11-18T07:02:07.637+00:00

Dear Team,

We have MS 365 account from where we want to perform MS 365 admin collection for an organization where an admin would be authenticated and we would like to collect sites/subsites data of any particular user within that organization.

Can you please advise us which API we should use for it as well as how to add the "createdBy" filter in the results retrieval process.
To retrieve the sites, we are utilizing the following API:
API: https://graph.microsoft.com/v1.0/sites?search=createdby: "UserDisplayName"
Using the above API, we are now receiving communication sites, however, we desire both communication sites and team sites.

Also, the following URL is used by us for authentication:
API: https://login.microsoftonline.com/organizations/v2.0/adminconsent

Microsoft 365 and Office | SharePoint | Development
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. HarmeetSingh7172 4,826 Reputation points
    2022-11-19T00:05:04.95+00:00

    Hello @Casepoint Developer

    Thanks for reaching out!

    Currently Site resource does not expose owner property. Per my understanding, the endpoint you are using to list sites created by a specfic user is not valid.

    Additionally, as per Search for sites documentation, the Search filter is a free text search that uses multiple properties when retrieving the search results. It searches for relevant sites which matches the keywords provided.

    However, to know the owner of a specific site, you could use this workaround:
    You can get the default library owner in the site. The default library owner would be the site owner. Below is the endpoint to get the sites drive, there is an owner property in the response:

    GET https://graph.microsoft.com/v1.0/sites/{site-id}/drive   
    

    ----------

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.