OneDrive / onedrive-sdk-csharp

OneDrive SDK for C#! https://dev.onedrive.com
Other
294 stars 143 forks source link

how to download shared content? #153

Closed ghost closed 2 weeks ago

ghost commented 8 years ago

How i can get content of child items in shared folder?

I'll get shared folder by Id or path: await client.ItemWithPath("/shares/s!AkYjBk5RIzQRl5pEOtEEcn9uGg38tg/items/113423514E062346!380228).Request().GetAsync();

if i append children item name i have exception... await client.ItemWithPath("/shares/s!AkYjBk5RIzQRl5pEOtEEcn9uGg38tg/items/113423514E062346!380228/fff.txt").Content.Request().GetAsync();

cdmayer commented 8 years ago

Check out the docs for Accessing Shared Content, especially the example at the bottom. Start with adding the 'root' keyword after the share ID:

"/shares/{sharingTokenOrUrl}/root?expand=children"

That will give you the children of the item (as long as it's a folder).

ghost commented 8 years ago

I'll get all childrens.. without content... Id, Created, Name, Size, etc... but how i can download content of any children?

my problem is not get childrens of folder, but get content of children

cdmayer commented 8 years ago

Ah, I see. Can you post the exception details?

ghost commented 8 years ago

BadRequestStorageException(BadRequest): Cannot provide a path relative to a property.

   at Microsoft.MSN.Storage.Api.CoreApi.Routing.ColonPathODataRoute.AddMatchToPath(StringBuilder pathBuilder, String encodedPath, Match match, HttpRequestMessage request, HttpRouteValueDictionary routeValueDictionary) in d:\dbs\sh\odht\0808_075130\cmd\34\server\storage\private\api\coreapi\Routing\ColonPathODataRoute.cs:line 377
   at Microsoft.MSN.Storage.Api.CoreApi.Routing.ColonPathODataRoute.GetRouteData(String virtualPathRoot, HttpRequestMessage request) in d:\dbs\sh\odht\0808_075130\cmd\34\server\storage\private\api\coreapi\Routing\ColonPathODataRoute.cs:line 169
   at System.Web.Http.HttpRouteCollection.GetRouteData(HttpRequestMessage request)
   at System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Web.Http.HttpServer.<SendAsync>d__0.MoveNext()

Code: invalidRequest Throw site: 1d8e.7118 Message: Bad Argument

Inner error Code: badRequest Throw site: 1d8e.7118

   at Microsoft.OneDrive.Sdk.HttpProvider.<SendAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.OneDrive.Sdk.BaseRequest.<SendRequestAsync>d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.OneDrive.Sdk.BaseRequest.<SendStreamRequestAsync>d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at CuteShopping.Models.ShoppingList.<OpenSharedAsync>d__28.MoveNext()
ghost commented 8 years ago

Try by ShareId -> ItemId: await client.Shares["s!AkYjBk5RIzQRl5pEOtEEcn9uGg38tg"].Items["113423514E062346!380229"].Content.Request().GetAsync();

All done :) Thanks!

ghost commented 8 years ago

hm... doesn't works... i need get first item content in shared folder:

var share = await client.Shares["s!AkYjBk5RIzQRl5pbFS3UedRrEUxw-g/root"].Request().GetAsync();
var items = await client.Shares["s!AkYjBk5RIzQRl5pbFS3UedRrEUxw-g"].Items[share.Id].Children.Request().GetAsync();
var r = await client.Shares["s!AkYjBk5RIzQRl5pbFS3UedRrEUxw-g"].Items[items[0].Id].Content.Request().GetAsync();

and i'll got: Unexpected exception returned from the service. on latest string with 'Content'

baywet commented 2 weeks ago

Thank you for reaching out and for your patience. This SDK is being officially deprecated. See #259 for more information