How can I upload a file to a personal OneDrive account?
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Start with the linked upload-file-to-onedrive example and the Go call using Drives().ByDriveId().Items().ByDriveItemId().Children().Post. Reproduce the two reported errors for personal and Microsoft 365 accounts, then determine whether the SDK supports this upload flow. Done means the supported behavior or required workflow is documented and verified.
Written by the indexing model from the issue text.
Description
Hi, I'm working on a service that will automatically upload files that a user has requested periodically to their OneDrive. While I've managed to get this working for users with a Microsoft 365 account, I haven't been able to successfully upload a file for users with a personal Microsoft account / to their personal OneDrive.
Does the this SDK support uploading files to a personal OneDrive, and if so how would I do that?
A short example of what I have working for a Microsoft 365 account is in this repository - https://github.com/chriswilding/upload-file-to-onedrive.
The same technique does not work for a personal OneDrive. With a Microsoft 365 OneDrive account I was only able to upload a file in a two step process, first PUTing the file, and the POSTing the content. With a personal OneDrive account both setting and not setting the content results in an error.
name := "example.txt"
contentType := "text/csv"
data := []byte("Hello,World!")
newFile := models.NewFile()
newFile.SetMimeType(&contentType)
fileItem := models.NewDriveItem()
fileItem.SetName(&name)
fileItem.SetAdditionalData(map[string]interface{}{
"@microsoft.graph.conflictBehavior": "replace",
})
fileItem.SetFile(newFile)
// When trying to upload to a personal OneDrive account, if the content is set the a error is returned -
// Error creating file item: [child] A stream property 'content' has a value in the payload. In OData, stream property must not have a value, it must only use property annotations.
// error: invalidRequest
// error: [child] A stream property 'content' has a value in the payload. In OData, stream property must not have a value, it must only use property annotations.
//
// However, if the content is not set then a different error is returned -
// Error creating file item: Cannot create a file without content
// error: invalidRequest
// error: Cannot create a file without content
// fileItem.SetContent(data)
createdFileItem, err := client.Drives().ByDriveId("aDriveID").Items().
ByDriveItemId("aParentDriveItem").Children().
Post(context.Background(), fileItem, nil)
- Dominant language
- Go
- Stars
- 335
- Forks
- 43
- Avg merge
- 15h 19m
- Merged PRs (30d)
- 3
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoftgraph/msgraph-sdk-go
-
ItemItemsItemPermanentDeleteRequestBuilderInternal.Post missing content body/content-type headersOpenstatus:waiting-for-triage type:bug
Difficulty 3/5 1-2 days Newbie friendliness 48/100
microsoftgraph/msgraph-sdk-go#980 ·
-
status:waiting-for-triage type:bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
microsoftgraph/msgraph-sdk-go#972 ·
-
status:waiting-for-triage type:bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
microsoftgraph/msgraph-sdk-go#969 · 1 comment ·
-
status:waiting-for-triage type:feature
Difficulty 3/5 1-2 days Newbie friendliness 45/100
microsoftgraph/msgraph-sdk-go#964 ·
-
status:waiting-for-triage type:feature
Difficulty 5/5 Over a week Newbie friendliness 20/100
microsoftgraph/msgraph-sdk-go#940 · 1 comment ·
All issues in microsoftgraph/msgraph-sdk-go
Similar issues
-
priority: low 🌱 type: enhancement 💅🏼
Difficulty 2/5 Half a day Newbie friendliness 84/100
nebari-dev/llm-serving-pack#199 ·
Maintainers usually reply within 3 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
area/helm kind/bug priority/backlog triage/accepted
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
lexfrei/cloudflare-tunnel-gateway-controller#889 ·
Maintainers usually reply within 1 day
-
bug difficulty: beginner documentation good first issue help wanted localization
Difficulty 1/5 Under an hour Newbie friendliness 90/100
wavefnd/wave-platform#140 ·
-
compiler/runtime
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day