Issue: Creating a SharePoint List Item Inside a Folder (Custom List) via Microsoft Graph

Abhishek-Kr Singh 0 Reputation points
2026-03-27T14:32:16.2733333+00:00

When working with a custom SharePoint list that uses folders (not a document library), creating a new item directly inside a folder using Microsoft Graph does not work as expected.

What I Tried:

Developers commonly attempt:

  • Setting parentReference.id to the folder’s list item ID
  • Setting parentReference.path
  • Using ETags
  • Creating the item via /lists/{list-id}/items

All of these approaches create the item at the root of the list, not inside the target folder.

I have used below code:

public async Task CreateListItemInFolderAsync(string folderName)

{

 // Step 1: Get the folder item

 var folderItems = await _graph.Sites[_siteId].Lists[_listInfo.ListId].Items

     .GetAsync(requestConfiguration =>

     {

         requestConfiguration.QueryParameters.Expand = new[] { "fields" };

         requestConfiguration.QueryParameters.Filter = $"fields/Title eq '{folderName}'";

     });

 var folderItem = folderItems.Value.FirstOrDefault();

 if (folderItem == null)

 {

     throw new Exception($"Folder '{folderName}' not found");

 }



 // Step 2: Create the list item at the root level

 var newItem = new ListItem

 {

     Fields = new FieldValueSet

     {

         AdditionalData = new Dictionary<string, object>

         {

             { "Title", "New Record 6" },

             // Add other custom fields here

             // { "YourColumnName", "Your Value" }

             }

         },

 };

 var createdItem = await _graph.Sites[_siteId].Lists[_listInfo.ListId].Items

     .PostAsync(newItem);

 Console.WriteLine($"Item created with ID: {createdItem.Id}");

 // Step 3: PATCH the item to set its parentReference to the folder

 var itemToUpdate = new ListItem

 {

     

     ParentReference = new ItemReference

     {

         Name = folderItem.Id,

     }

 };

 var updatedItem = await _graph.Sites[_siteId].Lists[_listInfo.ListId].Items[createdItem.Id]

     .PatchAsync(itemToUpdate);

 Console.WriteLine($"Item moved to folder '{folderName}' successfully");

 Console.WriteLine($"Updated item ID: {updatedItem.Id}");

}

Microsoft Security | Microsoft Graph
0 comments No comments

1 answer

Sort by: Oldest
  1. AI answer

    2026-03-27T14:32:32.67+00:00

    Creating a list item inside a folder of a custom (non-document-library) SharePoint list is not supported via the Microsoft Graph listItem APIs in the same way that moving driveItems between folders is supported in document libraries.

    The behavior observed is expected:

    • POST /sites/{site-id}/lists/{list-id}/items always creates the item at the root of the list.
    • Updating parentReference on a listItem does not move it into a folder.
    • The parentReference move pattern shown in Microsoft Graph applies to driveItem resources (files/folders in drives), not to list items in custom lists.

    The move semantics demonstrated in Graph are for driveItem:

    PATCH https://graph.microsoft.com/v1.0/me/drive/items/{item-id}
    Content-type: application/json
    
    {
      "parentReference": {
        "id": "{new-parent-folder-id}"
      },
      "name": "new-item-name.txt"
    }
    

    and in JavaScript:

    const driveItem = {
      parentReference: {
        id: '{new-parent-folder-id}'
      },
      name: 'new-item-name.txt'
    };
    
    await client.api('/me/drive/items/{item-id}').update(driveItem);
    

    These examples apply to OneDrive/SharePoint document libraries (drives), not to custom list items.

    For custom lists that use folders, Microsoft Graph documentation in the provided context only covers:

    • Creating list items at the list root:
        POST https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items
        Content-Type: application/json
        
        {
          "fields": {
            "Title": "Widget",
            "Color": "Purple",
            "Weight": 32
          }
        }
      
    • Creating folders and items as driveItem resources under a drive (document library) using:
        POST /drives/{drive-id}/items/{parent-item-id}/children
        POST /groups/{group-id}/drive/items/{parent-item-id}/children
        POST /me/drive/items/{parent-item-id}/children
        POST /sites/{site-id}/drive/items/{parent-item-id}/children
        POST /users/{user-id}/drive/items/{parent-item-id}/children
      

    There is no supported pattern in the provided documentation for targeting a folder within a custom list as the parent of a new listItem via Graph, nor for moving an existing listItem into such a folder via parentReference.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

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