Your workflow is unique 👨💻 - tell us how you use Dropbox here.
API
5856 TopicsUsing API and SDK together
Hello, I need some help until now i have been using >NET SDK Version 6.37. and we are experiencing a problem downloading large files 30GB and higher. so I tried to implement chunk download, but SDK does not support it . so I did it using the API. but my problem is that when we use the SDK we do not Need to refresh token. and when we use api after some time I am getting 401 . so I implemented a refresh token method, and refreshed the token , but still after sending the request again with the new token I got I am still getting the 401. I tried to get the token from the Dropbox Client but it is not there also regarding the refresh token , is this token always stays the same ? can some one help? adding some code snipped. public async Task<string> RefreshAccessTokenAsync(string expiredAccessToken,BaseRequest baserRequest,bool isBusinessClient, CancellationToken token) { using (var http = new HttpClient()) { var request = new HttpRequestMessage(HttpMethod.Post, "https://api.dropboxapi.com/oauth2/token"); var content = new FormUrlEncodedContent(new Dictionary<string, string> { { "grant_type", "refresh_token" }, { "refresh_token", baserRequest.RefreshToken }, { "client_id", isBusinessClient ?ClientIdBusiness : ClientId }, { "client_secret", isBusinessClient ? ClientSecretBusiness : ClientSecret } }); request.Content = content; using (var response = await http.SendAsync(request, token)) { response.EnsureSuccessStatusCode(); var json = await response.Content.ReadAsStringAsync(); dynamic result = Newtonsoft.Json.JsonConvert.DeserializeObject(json); string newAccessToken = result.access_token; if (string.IsNullOrEmpty(newAccessToken)) throw new Exception("Dropbox token refresh failed: access_token not returned."); return newAccessToken; } } } private async Task DownloadFileInChunksHttpAsync( string accessToken, string dropboxPath, string localPath, long fileSize, string asMember, string rootNamespaceId, CancellationToken token, BaseRequest baseRequest, bool isBusinessClient) // <-- tells refresh which client to use { DropboxTeamClient client; const int bufferSize = 1024 * 1024; // 1MB const long chunkSize = 50L * 1024 * 1024; // 50MB using (var fileStream = new FileStream(localPath, FileMode.Create, FileAccess.Write, FileShare.None)) using (var http = new HttpClient()) { string currentAccessToken = accessToken; long offset = 0; while (offset < fileSize) { long end = Math.Min(offset + chunkSize - 1, fileSize - 1); bool retriedAfterRefresh = false; RetryChunk: var request = new HttpRequestMessage(HttpMethod.Post, "https://content.dropboxapi.com/2/files/download"); // Authorization request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", currentAccessToken); // Dropbox-API-Arg (JSON-encoded) var arg = new { path = dropboxPath }; string jsonArg = Newtonsoft.Json.JsonConvert.SerializeObject(arg); request.Headers.Add("Dropbox-API-Arg", jsonArg); // Range header for chunking request.Headers.Range = new System.Net.Http.Headers.RangeHeaderValue(offset, end); // Act as team member (Business) if (!string.IsNullOrEmpty(asMember)) request.Headers.Add("Dropbox-API-Select-User", asMember); // Apply PathRoot (WithPathRoot) for Business only if (!string.IsNullOrEmpty(rootNamespaceId)) { var pathRoot = new Dictionary<string, object> { { ".tag", "root" }, { "root", rootNamespaceId } }; string jsonPathRoot = Newtonsoft.Json.JsonConvert.SerializeObject(pathRoot); request.Headers.Add("Dropbox-API-Path-Root", jsonPathRoot); } using (var response = await http.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token)) { // 🔐 Handle expired token (401) if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized) { if (retriedAfterRefresh) { var err = await response.Content.ReadAsStringAsync(); throw new HttpRequestException( $"Dropbox download failed after token refresh (401). Body: {err}"); } // Refresh token based on client type (Personal vs Business) currentAccessToken = await RefreshAccessTokenAsync(currentAccessToken, baseRequest, isBusinessClient, token).ConfigureAwait(false); retriedAfterRefresh = true; goto RetryChunk; } // ❌ Other errors if (!response.IsSuccessStatusCode) { var err = await response.Content.ReadAsStringAsync(); throw new HttpRequestException( $"Dropbox download failed: {(int)response.StatusCode} {response.ReasonPhrase}. Body: {err}"); } // ✅ Success using (var stream = await response.Content.ReadAsStreamAsync()) { fileStream.Seek(offset, SeekOrigin.Begin); await stream.CopyToAsync(fileStream, bufferSize, token); } } offset = end + 1; } } } public async Task<DownloadFileResponse> DownloadFileAsync(DownloadFileRequest request) { DropboxTeamClient client; var connectionId = GetDropboxTeamClient(request, out client); ////logsfodebug(request, "DownloadFileAsync"); var account = await client.AsMember(request.AsMember).Users.GetCurrentAccountAsync(); var spaceclient = client.AsMember(request.AsMember).WithPathRoot(new PathRoot.Root(account.RootInfo.RootNamespaceId)); bool newTeam = CheckIfUserIsUpdatedTeam(account); string tempFilename; if (request.ExportAs != null) { // ===== EXPORT: REVERTED TO OLD SDK CODE (AS REQUESTED) ===== tempFilename = await Retries.PerformWithRetriesAsync( async () => { var path = request.FilePath.Replace('\\', '/'); var fileInfo = await spaceclient.Files.GetMetadataAsync(path) .ConfigureAwait(false); if (fileInfo.IsDeleted) throw new CannotDownloadFileException(string.Format("File was Deleted. - {0}", path)); long? size = request.Size ?? (long)fileInfo.AsFile.Size; using (var safeTemporaryFileProvider = new SafeTemporaryFileProvider(() => PathExtensions.GetTempFileName(request.ContextId))) { using (var tokenSource = new CancellationTokenSource(TimeoutHelper.FromSize(size))) { // OLD SDK EXPORT CODE (unchanged) using (var downloadResponse = await spaceclient.Files .ExportAsync(new ExportArg(request.FilePath, null)) .WithCancellation(tokenSource.Token).ConfigureAwait(false)) { using (var fileStream = new FileStream(safeTemporaryFileProvider.TempFilename, FileMode.Create)) { var downloadStream = await downloadResponse.GetContentAsStreamAsync() .WithCancellation(tokenSource.Token) .ConfigureAwait(false); await downloadStream.CopyToAsync(fileStream, 4096, tokenSource.Token) .WithCancellation(tokenSource.Token) .ConfigureAwait(false); return safeTemporaryFileProvider.TempFilename; } } } } }, ShouldRetryWithDelay).ConfigureAwait(false); } else { if (newTeam) { // ===== BUSINESS / TEAM: NEW HTTP CHUNKED DOWNLOAD ===== tempFilename = await Retries.PerformWithRetriesAsync( async () => { var path = request.FilePath.Replace('\\', '/'); var fileInfo = await spaceclient.Files.GetMetadataAsync(path).ConfigureAwait(false); if (fileInfo.IsDeleted) throw new CannotDownloadFileException(string.Format("File was Deleted. - {0}", path)); long? size = request.Size ?? (long)fileInfo.AsFile.Size; using (var safeTemporaryFileProvider = new SafeTemporaryFileProvider(() => PathExtensions.GetTempFileName(request.ContextId))) { using (var tokenSource = new CancellationTokenSource(TimeoutHelper.FromSize(size))) { await DownloadFileInChunksHttpAsync( request.AccessToken, path, safeTemporaryFileProvider.TempFilename, size ?? 0, request.AsMember, account.RootInfo.RootNamespaceId, tokenSource.Token, request, true); // <-- Business client return safeTemporaryFileProvider.TempFilename; } } }, ShouldRetryWithDelay).ConfigureAwait(false); } else { // ===== PERSONAL: NEW HTTP CHUNKED DOWNLOAD ===== tempFilename = await Retries.PerformWithRetriesAsync( async () => { var path = request.FilePath.Replace('\\', '/'); var fileInfo = await client.AsMember(request.AsMember).Files.GetMetadataAsync(path).ConfigureAwait(false); if (fileInfo.IsDeleted) throw new CannotDownloadFileException(string.Format("File was Deleted. - {0}", path)); long? size = request.Size ?? (long)fileInfo.AsFile.Size; using (var safeTemporaryFileProvider = new SafeTemporaryFileProvider(() => PathExtensions.GetTempFileName(request.ContextId))) { using (var tokenSource = new CancellationTokenSource(TimeoutHelper.FromSize(size))) { await DownloadFileInChunksHttpAsync( request.AccessToken, path, safeTemporaryFileProvider.TempFilename, size ?? 0, request.AsMember, null, tokenSource.Token, request, false); // <-- Personal client return safeTemporaryFileProvider.TempFilename; } } }, ShouldRetryWithDelay).ConfigureAwait(false); } } var response = new DownloadFileResponse { LocalPath = tempFilename }; return UpdateTokens(response, request, client, connectionId); }161Views0likes7Commentslist_folder is not returning media info
I am sending a request using this endpoint: https://api.dropboxapi.com/2/files/list_folder And sending this data: { "path": "/Otter+Moon", "include_media_info": true, "include_has_explicit_shared_members": false, "include_mounted_folders": true } However, the media info is not being returned. This means that I have to send individual https://api.dropboxapi.com/2/files/get_metadata { "path": "/Otter+Moon/EmmaWolf_OtterandMoon-1.jpg", "include_media_info": true } for each file in that directory. Why? Why is the media info not being returned on the initial request?Receiving errors from Dropbox API
Hello we've had intermittent issues with the Dropbox API, where some users within our org are unable to upload pictures or docs. In our Kibana logging we are seeing this error occur: :Error= com.dropbox.core.NetworkIOException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target We are trying to narrow down why is error is occurring and if you need any additional info about our config please let me know.Solved296Views0likes5CommentsTeam Folder API access in a Standard plan
Forgive me if this information is already available, but I haven't immediately been able to find it. I'm in a scenario where I would like to sync data from a third-party application to team folders in dropbox. My organization is currently operating under a Standard license. I know team folders are a concept in a Standard plan, because I can create them. However, my understanding is that to use the API to send files to them specifically, I need to make use of team folder namespace Ids in my headers. And from what I can tell, there are several API endpoints to retrieve the namespace ID of a given folder, such as team/team_folder/get_info and files/get_metadata. However, while I can hit these endpoints, they do not retrieve any information about folder namepace Ids, and I think what I am now reading is that that information simply isn't available unless you are operating under a Business or Enterprise license. Is this conclusion accurate? Is there a way to retrieve / use team folder namespace Ids under a Standard license, to sync files to specific team folders? If so, how? Thanks in advance for your help, and sorry again if this information is already available and I'm just missing it.the names of the Certificate Authorities (CAs) changed
Hello Dropbox Developer Support, I am reviewing the recent root certificate changes described here:https://dropbox.tech/developers/api-server-certificate-changes We do not use an official Dropbox SDK, so we will not be directly affected by the root certificate change itself. However, I would like to confirm that the updated root and intermediate CA certificates are present in our trusted CA store. Could you please provide the names of the Certificate Authorities (CAs) for the following? - The new root certificate(s) - The updated intermediate certificate(s) This will help us verify trust chain presence in our environment. Thank you in advance. Best regards,/files/save_url has high rate of failure
Hi, I am currently testing using the /files/save_url API endpoint and am experiencing a high rate of failure. I am testing using a set of 6 small image files stored in S3-compatible storage environments, and using their public URLs with the aforementioned API endpoint. In every test run, there is at least one file that fails to be created in Dropbox, and it is a different file from the set each time. A file that fails in test #1 will succeed in tests #2, #3 and fail again in test #4 etc. These image files are standard .jpg files and generally 500kb or less. Upon checking the status of the API requests using /files/save_url/check_job_status, the failed IDs return the "download_failed" response. I know there is a 5 minute limit on file transfers using /files/save_url, however all these failed IDs are returning their failure response only a few seconds after initiating the API request. It may be worth mentioning that the API requests to /files/save_url are occurring all together. I don't believe the URLs are being rate-limited on the S3-compatible storage side, as it is tested with multiple environments, including self-hosted storage without such restrictions. Done some googling, found some users with the same issue, but unable to find anything that resolves the issue. Some example failed job IDs: nJekCKfZPnwAAAAAAAAAAQ aPQH1k_ei7cAAAAAAAAAAQ Is there a way to resolve this issue?1.4KViews0likes11CommentsEternal "in_progress" in "check_job_status" ?
Hi there! After creating the file transfer task, I did not get a status other than "in_progress". I checked for 10 minutes, the result is the same. https://api.dropboxapi.com/2/files/save_url Headers: Dropbox-API-Path-Root:{".tag":"root","root":"***11017011"} Content-Type:application/json Body: { "path": "/TrueCare24/Getting started.pdf", "url": "https://cdn.filestackcontent.com/4HanfOIvSVW4gHeOUbm9" } Response: { ".tag": "async_job_id", "async_job_id": "SPaPOLIucOYAAAAAAAAAAQ" } https://api.dropboxapi.com/2/files/save_url/check_job_status Headers: Dropbox-API-Path-Root:{".tag":"root","root":"***11017011"} Content-Type:application/json Body: { "async_job_id": "SPaPOLIucOYAAAAAAAAAAQ" } Response: { ".tag": "in_progress" } There are no problems with other files. I have transferred many thousands of files and everything is ok. TrueCare24 is Team Folder339Views0likes8CommentsSIEM integration with Webhook
Hello Everyone. We connected our SIEM to Dropbox with webhook, we sent test message and we received it in the SIEM solution. But the issue is that we don't see any loges bides test message. We want to receive audit logs and security logs. Please can anyone advice what should we do in this case we want to continue with webhook but i am not sure what is the issue that we are not receiving any logs. Thank you ).