i tried uploading a document through dwolla api library
const Client = require('dwolla-v2').Client;
const fs = require('fs');
const dwolla = new Client({
environment: "sandbox",
key: "key",
secret: "secret",
});
const customerUrl ="https://dashboard-sandbox.dwolla.com/customers/c1ba3805-9232-4ffe-a866-3fa60ea0cf60";
const requestBody = new FormData();
fs.readFile('icon.png', function(err, data) {
if (err) throw err;
if(data){
requestBody.append("file",new Blob([data]), {
filename: "document.png",
contentType: "image/png",
knownLength: fs.statSync("document.png").size,
});
requestBody.append("documentType", "license");
}
});
dwolla.post(`${customerUrl}/documents`, {
body: requestBody,
headers: {
'Content-Type': 'multipart/form-data'
}
}).then((res) => res.headers.get("location")) // => "https://api-sandbox.dwolla.com/documents/fb919e0b-ffbe-4268-b1e2-947b44328a16"
.catch((err) => {
console.error(err.body);//error codes
});
and i got an error like this:
{
code: ‘UnsupportedRequestContentType’,
message: ‘Invalid request Content-Type. multipart/form-data.’
}
i have confirmed that the document is loaded and in the right directory