You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

gagsbh's avatar
gagsbh
Helpful | Level 5
4 years ago

Dropbox API Upload Errors using .NET SDK

Hello Greg-DB,

 

We already have a Dropbox solution on production system that fetches and restore files.

Our solution uses Dropbox API SDK for .NET - https://github.com/dropbox/dropbox-sdk-dotnet

 

We set up 2 new Windows 2019 servers for QA Testing with our solution.

The download and upload APIs on these servers gives intermittent errors.

The upload/download speeds on these servers are about 100 Mbps.

 

Two days back it was giving errors, yesterday it worked and today it is again giving errors.

Upload API is giving more errors.

 

Can you help us know why are facing such issues on these new server ?

Which domain/IP/Port is used by the Dropbox API SDK for download and upload ?

 

Our error log captured the following exception stack trace for a file upload request:

 

Object reference not set to an instance of an object.
at Dropbox.Api.DropboxRequestHandler.GetRequestId(HttpResponseMessage response) in D:\Dropbox\Dropbox.Api\DropboxRequestHandler.cs:line 582
at Dropbox.Api.DropboxRequestHandler.<RequestJsonString>d__17.MoveNext() in D:\Dropbox\Dropbox.Api\DropboxRequestHandler.cs:line 476
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Dropbox.Api.DropboxRequestHandler.<RequestJsonStringWithRetry>d__15.MoveNext() in D:\Dropbox\Dropbox.Api\DropboxRequestHandler.cs:line 308
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Dropbox.Api.DropboxRequestHandler.<Dropbox-Api-Stone-ITransport-SendUploadRequestAsync>d__13`3.MoveNext() in D:\Dropbox\Dropbox.Api\DropboxRequestHandler.cs:line 212
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Dropbox.Business.DropboxApi.<Upload>d__53.MoveNext() in D:\Dropbox\Dropbox.Business\DropboxApi.cs:line 1703

 

Thanks,

Gagan

  • All Dropbox API calls use HTTPS, so they go to port 443 on the relevant Dropbox API servers, which, for uploading and downloading file content via the official .NET SDK, is content.dropboxapi.com.

     

    As for the error you're getting, can you let me know what version number of the SDK you have installed, and share the relevant code snippet that's running when you see this? Thanks in advance!

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

    All Dropbox API calls use HTTPS, so they go to port 443 on the relevant Dropbox API servers, which, for uploading and downloading file content via the official .NET SDK, is content.dropboxapi.com.

     

    As for the error you're getting, can you let me know what version number of the SDK you have installed, and share the relevant code snippet that's running when you see this? Thanks in advance!

    • gagsbh's avatar
      gagsbh
      Helpful | Level 5

      Greg-DB 

       

      Thank-you for the information !

       

      I am pasting a snippet below from AssemblyInfo.cs of Dropbox API SDK which suggest its v2 SDK.

       

      [assembly: AssemblyTitle("Dropbox.Api")]
      [assembly: AssemblyDescription("Official Dropbox .Net v2 SDK")]
      [assembly: AssemblyConfiguration("")]
      [assembly: AssemblyCompany("Dropbox Inc.")]
      [assembly: AssemblyProduct("Dropbox.Api")]
      [assembly: AssemblyCopyright("Copyright © Dropbox Inc")]
      [assembly: AssemblyTrademark("")]
      [assembly: AssemblyCulture("")]
      [assembly: AssemblyVersion("4.0.0")]
      [assembly: AssemblyFileVersion("4.0.6562")]

       

      I again got failure today while doing uploads on my both new QA servers.
      The uploads surprisingly worked fine yesterday.

       

      a. Our code that calls Dropbox API SDK method.

      DropboxClient client = new DropboxClient(accesstoken, config);
      FileMetadata fileMetadata = await client.Files.UploadAsync(remotePath, mode: WriteMode.Overwrite.Instance, autorename: false, body: stream);

       

      b. Dropbox API SDK method stack:

      - FileUserRoutes.cs

      public t.Task<FileMetadata> UploadAsync(string path,
      WriteMode mode = null,
      bool autorename = false,
      sys.DateTime? clientModified = null,
      bool mute = false,
      col.IEnumerable<global::Dropbox.Api.FileProperties.PropertyGroup> propertyGroups = null,
      io.Stream body = null)
      {
      var commitInfo = new CommitInfo(path, .....
      return this.UploadAsync(commitInfo, body);
      }


      - FileUserRoutes.cs

      public t.Task<FileMetadata> UploadAsync(CommitInfo commitInfo, io.Stream body)
      {
      return this.Transport.SendUploadRequestAsync<CommitInfo, FileMetadata, UploadError>(commitInfo, body, "content", "/files/upload", "user", global::Dropbox.Api.Files.CommitInfo.Encoder, global::Dropbox.Api.Files.FileMetadata.Decoder, global::Dropbox.Api.Files.UploadError.Decoder);
      }


      - DropboxRequestHandler.cs

      async Task<TResponse> ITransport.SendUploadRequestAsync<TRequest, TResponse, TError>(
      TRequest request,
      Stream body,
      string host,
      string route,
      string auth,
      IEncoder<TRequest> requestEncoder,
      IDecoder<TResponse> resposneDecoder,
      IDecoder<TError> errorDecoder)
      {
      ..
      var res = await this.RequestJsonStringWithRetry(host, route, auth, RouteStyle.Upload, serializedArg, body)
      .ConfigureAwait(false);
      ..
      ..
      }

      - DropboxRequestHandler.cs

      private async Task<Result> RequestJsonStringWithRetry(
      string host,
      string routeName,
      string auth,
      RouteStyle routeStyle,
      string requestArg,
      Stream body = null)
      {

      ..
      ..
      return await this.RequestJsonString(host, routeName, auth, routeStyle, requestArg, body)
      .ConfigureAwait(false);
      ..
      ..
      }


      - DropboxRequestHandler.cs

      private async Task<Result> RequestJsonString(
      string host,
      string routeName,
      string auth,
      RouteStyle routeStyle,
      string requestArg,
      Stream body = null)
      {
      ....
      ....
      var requestId = GetRequestId(response);
      ....
      ....
      }

       

      - DropboxRequestHandler.cs

      private string GetRequestId(HttpResponseMessage response)
      {
      IEnumerable<string> requestId;

      if (response.Headers.TryGetValues("X-Dropbox-Request-Id", out requestId))
      {
      return requestId.FirstOrDefault();
      }

      return null;
      }

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

        Thanks for the additional information. That doesn't look like the particular version information I was looking for though. Can you share the version number of the Dropbox SDK itself, e.g., as you installed via NuGet, for instance? The latest version is currently v6.6.2.

        Also, looking at the stack it looks like you are not on the latest version, so I recommend upgrading to that anyway, in case this issue is already resolved in the latest version.

        Anyway, I'm trying to reproduce this but I can't seem to. It works correctly for me, even after repeating the upload call many times, so please let me know if the upgrade helps.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,895 PostsLatest Activity: 42 minutes ago
328 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!