How to create and change a folder's content type using the MS Graph API



I need to create a folder using the Graph API, then change its content type and set metadata against it.

Ideally I would like to use SharePoint end points (/site/) to:

- Create the folder in a specific library

- Change the folders content type to a custom one

- Update metadata on the folder


Can anyone please provide me an example of doing this?


Many thanks!

1 Reply
best response confirmed by Nigel Witherdin (Contributor)
  • Create the folder: 

    POST /drives/{drive-id}/items/root/children


    "name": "{name}",

    "folder": { },

    "@microsoft.graph.conflictBehavior": "fail"


  • Get the created folder's item id: 
    GET /drives/{drive-id}/items/root:/{folder-name}?expand=sharepointIds
  • Update folder's content type and metadata:

    PATCH /sites/{site-id}/lists/{library-name}/items/{item-id}




        "id": "{content-type-id}"




      "field_1_name": "{field_1_value}",

      "field_2_name": "{field_2_value}"