Hi, When I upload an image or simulate the failed event works correctly but when I simulate the approved event I get an error that I have not found a solution.
Error: FetchError: request to https://api-sandbox.dwolla.com/customers/7e65577c-43a3-4935-a859-079ea8991ced/documents failed, reason: read ECONNRESET
at ClientRequest. (/var/task/node_modules/node-fetch/lib/index.js:1455:11)
at ClientRequest.emit (events.js:311:20)
at ClientRequest.EventEmitter.emit (domain.js:482:12)
at TLSSocket.socketErrorListener (_http_client.js:426:9)
at TLSSocket.emit (events.js:311:20)
at TLSSocket.EventEmitter.emit (domain.js:482:12)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
message: ‘request to https://api-sandbox.dwolla.com/customers/7e65577c-43a3-4935-a859-079ea8991ced/documents failed, reason: read ECONNRESET’,
type: ‘system’,
errno: ‘ECONNRESET’,
code: ‘ECONNRESET’
}
Hey @Efrain_Mtz can you specify if you are using the Dwolla Node SDK? And if so, please specify which version you are using?
This will help us investigate further.
Sure, I’m using dwolla-v2@^3.1.0 with NodeJS. Thanks @CoolStoryCory
Hi @Efrain_Martinez, are you able to share what some of your code looks like? Are there any variations in what you’re submitting for the success document versus the failure document? Those docs should be pretty much the same with the exception of the image and name.
Just wondering if this was resolved or not?
I am having similar issues.
In my case i am submitting the success document in sandbox, and here is what my code looks like
const createDwollaCustomerDocument = async (file, customerId) => {
try {
let customerId = 'a0312d81-6984-485f-908f-7320002aa9f8'
const customerUrl = `${dwollaApiUrl}/customers/${customerId}`;
const requestBody = new FormData();
requestBody.append('file', (file.path), {
filename: file.originalname,
contentType: file.mimetype,
knownLength: file.size
});
requestBody.append('documentType', 'license');
const response = await dwollaClient.post(`${customerUrl}/documents`, requestBody)
console.log("response:", response)
if(!response){
throw Error(
"Error uploading document"
)
}
if(response.status = 200)
{
return response.headers
}
} catch (error) {
console.log("Error in customer document upload:", error)
return error
}
}
i was able to fix it after adding fs.createReadStream in file
Thanks for posting an update @Pocket_Profit ! 
Hi @Pocket_Profit ,
Can you please share the code snippet which worked for you. I have been trying to fix this issues since a week, still I am getting the same reason: read ECONNRESET", error while uploading document. I am using createReadStream method as well.
Here is the code snippet
const { createReadStream, filename, mimetype, encoding } = await file;
var body = new FormData();
body.append(“file”, JSON.stringify(createReadStream()) {
filename: “mclovin.jpg”,
contentType: “image/jpeg”,
knownLength:2500
});
body.append(“documentType”, “license”);
await this.client.post(${customerURL}/documents, body);
I even tried this way.
body.append(“file”,fs.createReadStream(“test-document-upload-success.png”), {
filename: fileDetails.filename,
contentType: “image/png”,
knownLength:2500
// knownLength: fs.statSync(“test-document-upload-success.png”).size,
});
body.append(“documentType”, “license”);
But still no progress.
Sorry @Sandeep_Challa, I m just seeing this.
I do use multer with express and all is being done on backend/server side.
the snipet that worked for me is
const createDwollaCustomerDocument = async (file, customerId, documentType) => {
try {
const customerUrl = `${dwollaApiUrl}/customers/${customerId}`;
const requestBody = new FormData();
requestBody.append('file', fs.createReadStream(file.path), {
filename: file.originalname,
contentType: file.mimetype,
knownLength: file.size
});
requestBody.append('documentType', documentType);
const response = await dwollaClient.post(`${customerUrl}/documents`, requestBody)
if(!response){
throw Error("Error uploading document")
}
if(response.status = 200)
{
let location = response.headers.get('location')
const lastStringOfLocation = location.substring(location.lastIndexOf("/") + 1, location.length);
return lastStringOfLocation
}
if (response.status = 400){
return response.body.message
}
} catch (error) {
console.log("Error in customer document:", error)
return error
}
}