how to attach more than one file to a given smartsheet row by using without 4004 error

I have attached two attachments to a single row and got the following error. only one file was successfully connected to a given row of the smart sheet. I have called Attach file to row API endpoint with a loop. if I stay return the success message of each file attachment it will take much time and my API endpoint is useless. please guide me what is the best possible way to achieve this task.

POST /sheets/{sheetId}/rows/{rowId}/attachments

[error message ]=>

[Smartsheet] 2022-05-18T15:49:11.071Z[  WARN] Request failed, performing retry #1Cause: statusCode=500, date=Wed, 18 May 2022 15:49:10 GMT, content-type=application/json;charset=UTF-8, content-length=211, connection=close, server=Apache, vary=Accept-Encoding, content-encoding=gzip, x-envoy-upstream-service-time=123, x-smar-halo-version=1.1-821679-prod,

body={ "errorCode" : 4004,"message" : "Request failed because sheetId [smartsheetid] is currently being updated by another request that uses the same access token. Please retry your request once the previous request has completed.",

 "refId" : "1vmo74qbn41ro"

}


code snippet :

files.map(element => {  var uploadingFileOptions = {

      sheetId: [smartsheet id]

      rowId: [row id],

      fileSize: fs.statSync(element).size,

      fileName:'testfilename.pdf',

      fileStream: fs.createReadStream(element)

    };

  res.send(uploadingFileOptions)

  smartsheet.sheets.addRowFileAttachment(uploadingFileOptions)

.then(function (attachment) {

    console.log(attachment)

  })

  .catch(function (error) {

    console.log(error)

  });

});

   

Answers