-2

Using Oauth 2.0 i have authorized the user, got the access token and refresh token, using access token how to upload file to one drive

  • Due lack of information provided (Technologies used and so on), i will give it a shot in the dark: have a look at this: https://code.msdn.microsoft.com/How-to-upload-file-to-21125137/sourcecode?fileId=158961&pathId=1503686119 OR MS Graph => https://stackoverflow.com/questions/49822779/upload-new-file-to-onedrive-using-microsoft-graph-c-sharp-asp-net – Dimitri Apr 05 '19 at 08:47
  • I am using c# ,web core api 2.0 using MS Graph to upload file/download to/from one drive and sharepoint. I am looking for sample to upload file/download to/from one drive and sharepoint – Savita Jaswal Apr 08 '19 at 05:40

1 Answers1

0

There is a LOT of official documentation about this topic.

This is the documentation for Downloading a file where you could take a look at:

GET /drives/{drive-id}/items/{item-id}/content
GET /groups/{group-id}/drive/items/{item-id}/content
GET /me/drive/root:/{item-path}:/content
GET /me/drive/items/{item-id}/content
GET /sites/{siteId}/drive/items/{item-id}/content
GET /users/{userId}/drive/items/{item-id}/content

and this is for Uploading

HTTP request (to replace an existing item)

PUT /drives/{drive-id}/items/{item-id}/content
PUT /groups/{group-id}/drive/items/{item-id}/content
PUT /me/drive/items/{item-id}/content
PUT /sites/{site-id}/drive/items/{item-id}/content
PUT /users/{user-id}/drive/items/{item-id}/content

HTTP request (to upload a new file) HTTP

PUT /drives/{drive-id}/items/{parent-id}:/{filename}:/content
PUT /groups/{group-id}/drive/items/{parent-id}:/{filename}:/content
PUT /me/drive/items/{parent-id}:/{filename}:/content
PUT /sites/{site-id}/drive/items/{parent-id}:/{filename}:/content
PUT /users/{user-id}/drive/items/{parent-id}:/{filename}:/content

Also here is the documentation about Drives and DriveItems

Dimitri
  • 1,185
  • 2
  • 15
  • 37
  • Thanks , but issue is when trying to call these api, returning error "unauhtneticate token ". Now i am trying using :- var uploadedFileOnedrive = await graphClient.Me.Drive.Root.ItemWithPath(fileName).Content.Request().PutAsync(fileStream); its working for creating file on root for one drive but i need to create file inside particular folder. Also need to Create file to Sharepoint. – Savita Jaswal Apr 08 '19 at 07:48
  • Than we need more code in order to provide any decent help. Show us how you are requesting your Token to start, but provide any code that can help us help you. – Dimitri Apr 08 '19 at 08:02