尝试通过 Dropbox SDK 访问 Dropbox API 时出现错误 500
Error 500 when trying to access Dropbox API via Dropbox SDK
我有一个应用程序通过 Dropbox Javascript SDK 尝试下载文件。我不知道出了什么问题。通过 fetch 调用访问 Dropbox API 直接导致同样的错误。
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);
}
}
}
错误如下:
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}}
您必须以正确的方式connect/authorize,参见the documentation。
我有一个应用程序通过 Dropbox Javascript SDK 尝试下载文件。我不知道出了什么问题。通过 fetch 调用访问 Dropbox API 直接导致同样的错误。
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);
}
}
}
错误如下:
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}}
您必须以正确的方式connect/authorize,参见the documentation。