Problem getting a folder when running .NET SDK sample application ShareFile.Sample.Console

  • 1
  • Question
  • Updated 10 months ago

I am running the ShareFile.Sample.Console sample application from the ShareFile-NET repository. In the RunSample method, I get an error when I get to the LoadFolderAndChildren method call: 

System.AggregateException  HResult=0x80131500
  Message=One or more errors occurred.
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at ShareFile.Sample.Program.Main(String[] args) in C:\Users\ltse\Desktop\ShareFile.Sample\ShareFile.Sample\Program.cs:line 38
Inner Exception 1:
ODataException: Item not found: The item that you requested could not be found in the system.

I have created a folder, and added a file and another folder inside of that folder by logging into I'm using the same username and password, along with the client ID and client secret created by that user.

Could you help me understand why I'm not able to find the folder? Could it be something configuration-related that needs to be managed in the account/folder settings?

Photo of Lucas


  • 3 Posts
  • 0 Reply Likes
  • confused

Posted 10 months ago

  • 1
Photo of Lucas


  • 3 Posts
  • 0 Reply Likes
So apparently, the API user account doesn't have the "My Files & Folders" feature enabled. Our system administrator can't find a way to enable this for a user. This resulted in the ShareFile.Sample.Console application failing in the LoadFolderAndChildren(ShareFileClient sfClient) method on the line:
var folder = (Folder)await sfClient.Items.Get().Expand("Children").ExecuteAsync();

I modified this to use Items.ByPath(string path), using a path to a folder that the API user account had the necessary permissions to rather than Items.Get(), because the authenticated user does not have a default folder.

var folder = (Folder)await sfClient.Items.ByPath("/ExampleFolder").Expand("Children").ExecuteAsync();

The sample application works now and I have been able to start development on the application we'll be integrating with ShareFile through the .NET SDK.

The .NET SDK has barely any example code or documentation available. This has made it extremely difficult to perform even simple tasks.

For example, I want to check if a User exists by email address. Should I use a ShareFileClient instance sfClient and call the sfClient.Users.Get(emailAddress: "").ExecuteAsync()? An exception is thrown if a User with the provided email address does not exist. I'd rather not use a thrown exception to determine if a User exists; there has to be a simpler way. But I cannot find any documentation or examples that demonstrate a better way of doing this!

Could whoever is in charge of the .NET SDK please either: 
  • Add more example code to the sample applications included in the .NET Sample Solution? 
  • Add more examples on the GitHub repository landing page?
  • Start a Wiki for the repository?

The GitHub page for the .NET SDK suggests familiarizing oneself with the REST API. This at least makes me aware of the capabilities of the REST API, but it gives me little insight into the capabilities of the .NET SDK.

The OData Implementation page on the REST API Documentation site links to the ODATA website, which has some C# examples on its Understanding OData in 6 Steps. This is the first link listed under Getting Started, which is the first resource listed on the site's main page. It would be very helpful if there were documentation like this for the .NET SDK. The documentation currently available on the ShareFile SDK for .NET is so lacking that it is nearly impossible determine its capabilities.

There is some C# sample code on the REST API documentation site as well, but the heading on that page recommends only using that code if "you are working on a legacy project running a .NET Framework version older than 4.5". That is not the case for me, so I am following the suggested route of using the ShareFile SDK for .NET.

This forum is pretty much the only other resource available aside from the REST API documentation and the limited samples provided on the GitHub page, yet this simple question I posted a week ago received no response. I've seen many unanswered questions on this forum in which the answer would have been very helpful to me as well as the person who asked it, and likely other API users. Questions that have been answered by Employees and Reps have been helpful. I've seen them provide code samples for specific questions (and it would be nice if these samples could also be added to the yet-to-be-created GitHub Wiki for the .NET SDK so there is a central location for code samples!)

Could ShareFile/Citrix invest more in answering questions posted on this forum since the .NET SDK documentation is so sparse, yet it is the recommended mechanism for integrating non-legacy .NET applications with ShareFile?