Ok I fixed it. The problem was with the reader. Once the reader's job is done for the first time, the data is no longer null. So, it will not call for the api. Also, the index is not zero.
So, making data null and index 0 in @AfterStep fixed it for me.