1
votes

I am using Graph API for creation of Teams and then channels. But after the creation of a channel I want to add some empty folders inside that. How can Achieve this using graph API ? Team -> Channel -> File -> Folders

1

1 Answers

2
votes

You need to get the metadata for the location where the folders or files of a channel are stored.

GET /teams/{id}/channels/{id}/filesFolder

The response returns driveItem resource with driveId and driveItem's id.

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams('32e3b156-66b2-4135-9aeb-73295a35a55b')/channels('19%3Af253e46c035b42308e9a4a22a87037af%40thread.skype')/filesFolder/$entity",
    "id": "01H7CFEKENJSSIUHGADZBKODARINQC5JMD",
    "createdDateTime": "0001-01-01T00:00:00Z",
    "lastModifiedDateTime": "2020-01-23T18:47:13Z",
    "name": "Documentation Planning",
    "webUrl": "xxx",
    "size": 2374080,
    "parentReference": {
        "driveId": "b!2SInBlQrN0K8-GXMy9qNsPtI5ScW8C5IlZtycoy6ZpJZRRtgE4qVTrE8wrvL0-hd",
        "driveType": "documentLibrary"
    },
    ...
}

Then you can create a new folder by calling the endpoint:

POST /drives/{driveId}/items/{id}/children

Get files folder

Create folder