Create a Sharepoint list in a specific folder with Microsoft graph api

Shankar, Pankaja 1 Reputation point
2023-01-03T19:19:17.79+00:00

Premise: I have a folder under the sharepoint site for e.g. https://... <mycompany-sharepoint-site.com>/ under which we have folder so my url is something like https://... <mycompany-sharepoint-site.com>/Documents/Sub_folder_1/Sub_folder_12 pertaining to our project.

I need to be able to create a Sharepoint list in the Sub_folder_2 - folder and not at the root level.

With Sharepoint - GraphApi - create list api url

POST https://graph.microsoft.com/v1.0/sites/{site-id}/lists

I will ONLY be able to create at the <mycompany-sharepoint-site.com> level (i.e. at the root level) which is not what I want.

FYI, I already tried (on Postman) to go with the drives/<drive_id>/items/<folder_id> - route or I should say attempted to do so but failed.
I tried including the parentReference something like this
"parentReference": {
"driveType": "documentLibrary",
"driveId": "b....",
"path": "/drives/b.../root:/Sub_folder_1/Sub_folder_12"
}
Even with the above the list is created at the site - root ONLY and not under Sub_folder_1/Sub_folder_12.

Any help is greatly appreciated.

Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. HarmeetSingh7172 4,826 Reputation points
    2023-01-03T21:11:35.777+00:00

    Hello @Shankar, Pankaja

    Thanks for reaching out!

    As per my understanding, creating a SharePoint list in a specific folder is not supported. Hence, it is not possible to achieve the same using Graph API.

    Lists are stand-alone objects and cannot be nested within each other. Managing lists inside a folder is not supported. Currently, using Graph API you can create lists at a root level.

    For creating a SharePoint list using graph API, please refer this documentation.

    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

  2. Shankar, Pankaja 1 Reputation point
    2023-01-03T21:20:28.157+00:00

    I know how to create a Sharepoint list at the root of a site. The issue is anyone who has access to the site will have access to the lists. We wanted to create for our own groupdepartment in a specific folder, so there's at least some amount of separation, even if someone who has access to the site itself.

    I cannot accept this answer as final, I am sure at some point Microsoft Graph Api folks will come up with a solution to create lists in a specific folder.


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.