microsoftgraph / msgraph-sdk-go-core

Microsoft Graph SDK for Go - Core Library
https://learn.microsoft.com/graph/sdks/sdks-overview
MIT License
20 stars 10 forks source link

Issue creating upload session on a folder #325

Closed MilitsaB closed 1 month ago

MilitsaB commented 1 month ago

I am trying to create an upload session to upload a file in a folder in Sharepoint. I am receiving the following error: Cannot create an upload session on a folder. I understand that an upload session cannot be created on a folder, however I am not sure how I can create one.

This is what I am currently doing:

uploadSession, err := graphClient.
        Drives().ByDriveId(driveID).
        Items().ByDriveItemId(folderID).
        CreateUploadSession().
        Post(ctx, uploadSessionRequestBody, nil)

I noticed that the msgraph-sdk-net has a method ItemWithPath which is not available in the Go version (https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/1353)

var uploadSession = await graphClient.Sites["site-id"].Drive.Items["folderId"].ItemWithPath("file.txt")
                            .CreateUploadSession(uploadProps)
                            .Request()
                            .PostAsync();

Any ideas on how I can do this using msgraph-sdk-go?

rkodev commented 1 month ago

Hi @MilitsaB, thanks for trying out the SDK. Are you able to test this example i.e concatenate the folderID + itemPath + ":"


uploadSession, _ := graphClient.Drives().
    ByDriveId(*myDrive.GetId()).
    Items().
    ByDriveItemId(folderID + "/"+"file.txt"+":").
    CreateUploadSession().
    Post(context.Background(), uploadSessionRequestBody, nil)
microsoft-github-policy-service[bot] commented 1 month ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.