cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We want to make our Community work for you and we need your help. Take our short survey!
Close

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error 400 when trying to access Dropbox API via Dropbox SDK

Highlighted

Error 400 when trying to access Dropbox API via Dropbox SDK

Explorer | Level 3

I have an app that via Dropbox Javascript SDK trying to download the file. I don't have any idea what is wrong. Accessing Dropbox API via fetch calls directly giving the same error. Dropbox API documentation saying that error 400 is for bad input parameters while it looks like what I'm sending is ok - "Dropbox-API-Arg":"{\"path\":\"/1/price.xlsx\"}"

const Dropbox = require("dropbox").Dropbox;
import axios from "axios";
import { logger } from "./logger";

export class FileHandler {
    public async handle(path: string, token: string): Promise<void> {
        try {
            const dbx = new Dropbox({ fetch: axios, accessToken: token });            
dbx
.filesDownload({ path }) .then((data) => {
console
.log(data); }) .catch((error) => {
logger
.error(error); }); } catch (err) {
logger
.error(err); } } }

Error is the follow

Request failed with status code 500 {"stack":"Error: Request failed with status code 500\n    at createError (/Users/andreyshedko/Repositories/agroproject-ftp/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/Users/andreyshedko/Repositories/agroproject-ftp/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/Users/andreyshedko/Repositories/agroproject-ftp/node_modules/axios/lib/adapters/http.js:237:11)\n    at IncomingMessage.emit (events.js:203:15)\n    at IncomingMessage.EventEmitter.emit (domain.js:448:20)\n    at endReadableNT (_stream_readable.js:1129:12)\n    at process._tickCallback (internal/process/next_tick.js:63:19)","config":{"url":"https://content.dropboxapi.com/2/files/download","method":"post","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/x-www-form-urlencoded","Authorization":"Bearer ...","Dropbox-API-Arg":"{\"path\":\"/1/price.xlsx\"}","User-Agent":"axios/0.19.0"},"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1}}

 

1 Accepted Solution

Accepted Solutions
Highlighted

Re: Error 400 when trying to access Dropbox API via Dropbox SDK

Dropboxer
Dropboxer

[Cross-linking for reference: https://stackoverflow.com/questions/59510091/error-400-when-trying-to-access-dropbox-api-via-dropbox... ]

First, can you clarify if you're getting a 400 error or a 500 error from the Dropbox API? Your subject says you're getting a 400, but the error output you're getting mentions a 500. These error codes would indicate different kinds of issues.

If you're getting a 400, that does indicate that there is an issue with your request. In that case, the 'error' in your 'catch' block should contain a more specific error message.

If you're getting a 500, that would indicate something went wrong on the Dropbox API servers, in which case we'd need to do some investigation on our side.

I do notice that you're using axios as your fetch client though. That's not officially supported, so please try switching to a different client. You can find more information in this thread.

View solution in original post

1 Reply 1
Highlighted

Re: Error 400 when trying to access Dropbox API via Dropbox SDK

Dropboxer
Dropboxer

[Cross-linking for reference: https://stackoverflow.com/questions/59510091/error-400-when-trying-to-access-dropbox-api-via-dropbox... ]

First, can you clarify if you're getting a 400 error or a 500 error from the Dropbox API? Your subject says you're getting a 400, but the error output you're getting mentions a 500. These error codes would indicate different kinds of issues.

If you're getting a 400, that does indicate that there is an issue with your request. In that case, the 'error' in your 'catch' block should contain a more specific error message.

If you're getting a 500, that would indicate something went wrong on the Dropbox API servers, in which case we'd need to do some investigation on our side.

I do notice that you're using axios as your fetch client though. That's not officially supported, so please try switching to a different client. You can find more information in this thread.

View solution in original post

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?