I have tried the above approach, but it was adding only one file due to asynchronous nature of the code. I have created another recursive solution to attach multiple files to list item. Code_Screenshot1
Code_Screenshot2