Upload document - Invalid request Content-Type

Hello Community, I need your help to upload a document
I did several tests but I receive the same error: Invalid request Content-Type. multipart/form-data.

Here are some details of the request, the versions of the packages and the error that I receive:
Env: Nodejs
Package versions:

  • dwolla-v2: 3.1.2
  • form-data: 2.5.1

Request:
const requestBody = new FormData();

requestBody.append('file', fs.createReadStream(file), {
  filename: name,
  contentType: 'image/png',
  knownLength: fs.statSync(file).size
});
requestBody.append('documentType', 'license');

const endpoint = `customers/${customerId}/documents`;
return requestDwollaAPI(POST, endpoint, requestBody);

Error:
{ err:
{ Error: {“code”:“UnsupportedRequestContentType”,“message”:“Invalid request Content-Type. multipart/form-data.”}
at errorFrom (/home/ismail/Developement/sharegro/sharegro-api/gate/node_modules/dwolla-v2/src/dwolla/Token.js:49:15)
at /home/ismail/Developement/sharegro/sharegro-api/gate/node_modules/dwolla-v2/src/dwolla/Token.js:70:29
at tryCatcher (/home/ismail/Developement/sharegro/sharegro-api/gate/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/ismail/Developement/sharegro/sharegro-api/gate/node_modules/bluebird/js/release/promise.js:517:31)
at Promise._settlePromise (/home/ismail/Developement/sharegro/sharegro-api/gate/node_modules/bluebird/js/release/promise.js:574:18)
at Promise._settlePromise0 (/home/ismail/Developement/sharegro/sharegro-api/gate/node_modules/bluebird/js/release/promise.js:619:10)
at Promise._settlePromises (/home/ismail/Developement/sharegro/sharegro-api/gate/node_modules/bluebird/js/release/promise.js:699:18)
at _drainQueueStep (/home/ismail/Developement/sharegro/sharegro-api/gate/node_modules/bluebird/js/release/async.js:138:12)
at _drainQueue (/home/ismail/Developement/sharegro/sharegro-api/gate/node_modules/bluebird/js/release/async.js:131:9)
at Async._drainQueues (/home/ismail/Developement/sharegro/sharegro-api/gate/node_modules/bluebird/js/release/async.js:147:5)
at Immediate.Async.drainQueues [as _onImmediate] (/home/ismail/Developement/sharegro/sharegro-api/gate/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
at process.topLevelDomainCallback (domain.js:126:23)
status: 415,
headers: Headers { [Symbol(map)]: [Object] },
body:
{ code: ‘UnsupportedRequestContentType’,
message: ‘Invalid request Content-Type. multipart/form-data.’ } } }

Hi @ismail – would you be able to share the Customer ID for whom you got the error trying to upload the document? I could take a look at what we’re receiving in the request.

I just tried the request with the following versions and I was able to get a successful response -

 "dwolla-v2": "^3.1.2",
 "form-data": "^3.0.0"