We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
gagsbh
4 years agoHelpful | Level 5
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-dotn...
- 4 years ago
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
Dropbox 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
4 years agoHelpful | Level 5
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-DB4 years agoDropbox 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.
- gagsbh4 years agoHelpful | Level 5
Hello Greg-DB
Thank-you for the information.
I upgraded the Dropbox API to v 6.6.2 and converted all my .NET projects to target .Net Framework 4.7.2.
The uploads were working fine yesterday and today morning but since last couple of hours I started getting the following exception during uploads.The exception is thrown at this line in our Business logic code.
fileMetadata = await client.Files.UploadAsync(remotePath, mode: WriteMode.Overwrite.Instance, autorename: false, body: stream);
Please see exception stack trace below:
An error occurred while sending the request.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Dropbox.Api.DropboxRequestHandler.<RequestJsonString>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Dropbox.Api.DropboxRequestHandler.<RequestJsonStringWithRetry>d__18.MoveNext()
--- 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 Dropbox.Api.DropboxRequestHandler.<Dropbox-Api-Stone-ITransport-SendUploadRequestAsync>d__13`3.MoveNext()
--- 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 C:\Dropbox\Business\DropboxApi.cs:line 1703The files being uploaded were 404 KB each in size.
This might be an issue local to our server or network.
What do we need to check at our end to find if this is our local issue ?For larger files we use UploadSessionStartAsync for file uploads.
With the new Dropbox API v6.6.2, UploadSessionStartAsync takes UploadSessionType as argument.
UploadSessionType can be Sequential, Concurrent or Other.
Which value should we choose for UploadSessionType and when ?Can you please help us again.
Thanks,
Gagan- Greg-DB4 years agoDropbox Staff
Thanks for upgrading and letting me know.
Can you confirm if this is the full output you're getting now though? It seems to be a different kind of issue than seen in your original post. (For instance, it no longer says "Object reference not set to an instance of an object" or the GetRequestId method.)
Anyway, since it is not occurring for me, and I don't believe we've received other reports of an issue like this, it may be related to your particular environment. Is there anything on your network connection, such as a firewall, proxy, etc. that may be interfering with your connection to content.dropboxapi.com?
Also, "Sequential" is the default for UploadSessionType, so you should be using that unless you've specifically implemented the "Concurrent" type. (The "Concurrent" type is a new feature that allows you to upload multiple pieces of a file for a particular upload session in parallel.)
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 7 hours agoIf 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!