Forum Discussion

STEALTHbits's avatar
STEALTHbits
Explorer | Level 4
4 years ago

Dropbox.Api.Sharing.ListFileMembersAsync Invalid Path after passing FileMEtadata.Id

A customer of ours is running into the error below:

System.ArgumentOutOfRangeException: Value should match pattern '\A(?:((/|id:).*|nspath:[0-9]+:.*)|ns:[0-9]+(/.*)?)\z' Parameter name: file

at Dropbox.Api.Sharing.ListFileMembersArg..ctor(String file, IEnumerable`1 actions, Boolean includeInherited, UInt32 limit)

at Stealthbits.StealthAUDIT.DataCollectors.Dropbox.Tasks.Scan.DropboxScanHelper.<>c__DisplayClass58_4.<ProcessResources>b__6()

at Stealthbits.StealthAUDIT.DataCollectors.Dropbox.Tasks.Scan.DropboxScanHelper.AwaitReturn[TResult](Func`1 callback)"

 

I censored the path for the customer but the structure is the same as the path below.
Failed to process resource /3- Folder1/1 - Folder2/Folder3 - Folder3 - Folder3/1 - Folder4/01.23.4567: File File_File_01.23.4567.pdf

 

Code using Dropbox 4.9.4, I will try updating to 5.5.0 (6.8 is giving me dependency errors):

 

 

userClient = client.AsMember(member.Profile.TeamMemberId);
adminClient = userAdmin.WithPathRoot(new PathRoot.NamespaceId(namespaceID));
var FolderContents = AwaitReturn(() => adminClient.Files.ListFolderAsync(namespaceID, false, true, false, true));
var entries = FolderContents.Entries;
while (FolderContents.HasMore)
{
    FolderContents = AwaitReturn(() => adminClient.Files.ListFolderContinueAsync(FolderContents.Cursor));
    foreach (var entry in FolderContents.Entries)
    {
	    entries.Add(entry);
    }
}


foreach (Metadata resource in entries)
{
    if (resource.IsFile)
    {
        List<Sharing.UserMembershipInfo> users = new List<Sharing.UserMembershipInfo>();
        FileMetadata fileData = resource.AsFile;
        //Errors here
        var fileMembers = AwaitReturn(() => 
        userClient.Sharing.ListFileMembersAsync(fileData.Id));
        users.AddRange(fileMembers.Users);

        while (!String.IsNullOrEmpty(fileMembers.Cursor))
        {
            fileMembers = AwaitReturn(() => userClient.Sharing.ListFileMembersAsync(fileMembers.Cursor));
							 
            users.AddRange(fileMembers.Users);
        }

        foreach (var member in users)
        {
            //Process member
        }
    }
}


TResult AwaitReturn<TResult>(Func<Task<TResult>> callback)
{
    using (Task<TResult> task = callback())
    {
	    task.Wait();
	    return task.Result;
    }
}

 

 

 

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    I see you're making the second ListFileMembersAsync call like this:

    userClient.Sharing.ListFileMembersAsync(fileMembers.Cursor)

     However, to retrieve more results via the cursor, you should actually call ListFileMembersContinueAsync, not ListFileMembersAsync.

    • STEALTHbits's avatar
      STEALTHbits
      Explorer | Level 4

      That could be it, our test environment probably never reached that case, thank you.  I will mark this as the answer when I hear back from the customer.

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API
Make connections with other developers804 PostsLatest Activity: 4 days ago
217 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!