cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know what we learned at IBC? Check out our learnings on media, remote working and more right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

File Download API Exception

File Download API Exception

gagsbh
Helpful | Level 5
Go to solution

Hello @Greg-DB 

 

Recently, there were changes made in the code related to Dropbox Teamspaces.

We are now facing errors sometimes when we download files that were notified with file paths by webhooks.


Using webhooks, we obtain the path of the recently added file in the account and then download using Dropbox APIs.
In the below case, the file added is /Boolean Array/Boolean Array/12/SOBR10.png

 

Error Details:

  • File Path: /Boolean Array/Boolean Array/12/SOBR10.png

  • Error Message: no_permission/.

    Stack Trace:

    no_permission/.
    at Dropbox.Api.DropboxRequestHandler.<RequestJsonString>d__20.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 Dropbox.Api.DropboxRequestHandler.<RequestJsonStringWithRetry>d__18.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 Dropbox.Api.DropboxRequestHandler.<Dropbox-Api-Stone-ITransport-SendDownloadRequestAsync>d__14`3.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 Dropbox.Ongoing.FetchBiz.Service1.<Download>d__40.MoveNext() in Ongoing.Fetch.cs:line 2321
 
Code Snippet:

//token is OAuth token generated by OAuth authentication grant provided by Team Admin
using (DropboxTeamClient teamclient = new DropboxTeamClient(token, appkey, appsecret))
{
DropboxClient clientadmin = teamclient.AsMember(dropboxid);
//dropboxid can be id of admin or normal user

Api.Users.FullAccount acc = await clientadmin.Users.GetCurrentAccountAsync();
string rootnamespace = "";

if (acc != null && acc.RootInfo != null && acc.RootInfo.RootNamespaceId != null)
{
rootnamespace = acc.RootInfo.RootNamespaceId;
clientadmin = clientadmin.WithPathRoot(new PathRoot.NamespaceId(rootnamespace));

//Below is Line 2321
using (var response = await clientadmin.Files.DownloadAsync(path))
{
....
}
}
}

 
 Can you please help us with this issue?

 

Thanks,

Gagan

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

Thanks for following up. To be clear, you should not be adding "/root" to the path itself, as that's not a path component (unless some user/app literally made a folder named "root"). You can use PathRoot.Root with a root namespace ID just like you used PathRoot.NamespaceId.

 

That is, modifying your original code, that would look like:

                    clientadmin = clientadmin.WithPathRoot(new PathRoot.Root(rootnamespace));

 

View solution in original post

4 Replies 4

Greg-DB
Dropbox Staff
Go to solution

I see you're attempting to access the user's root namespace, in which case it's generally best to use the PathRoot.Root mode instead of PathRoot.NamespaceId. Please give that a try and let me know what you get.

gagsbh
Helpful | Level 5
Go to solution

@Greg-DB 

 

Thank you for your reply.

How do I use PathRoot.Root mode in my c# code.

 

I changed the path parameter in my existing code from /Boolean Array/12/SOBR10.png, it gives error 'Path not found'.

to /root/Boolean Array/12/SOBR10.png

 

Then I tried changing the code:

using (var response = await dbx.Files.DownloadAsync(new Dropbox.Api.Files.DownloadArg(dropboxFilePath, pathRoot: new Dropbox.Api.PathRoot { Tag = Dropbox.Api.PathRoot.Tag.Root })))

 

Visual Studio gave compilation error:

The type or namespace name 'PathRoot' does not exist in the namespace 'Dropbox.Api' (are you missing an assembly reference?)

The best overload for 'DownloadArg' does not have a parameter named 'pathRoot'

 

Please suggest.

 

Thanks,

Gagan

Greg-DB
Dropbox Staff
Go to solution

Thanks for following up. To be clear, you should not be adding "/root" to the path itself, as that's not a path component (unless some user/app literally made a folder named "root"). You can use PathRoot.Root with a root namespace ID just like you used PathRoot.NamespaceId.

 

That is, modifying your original code, that would look like:

                    clientadmin = clientadmin.WithPathRoot(new PathRoot.Root(rootnamespace));

 

gagsbh
Helpful | Level 5
Go to solution

@Greg-DB Thank-you for the help. This worked for me.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    gagsbh Helpful | Level 5
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?