Case 1: I need to insert bulk users using excel(xls).
What I implemented:
URL: [POST] {{base_url}}/users/bulk
Content: Form Data-MultiPart
Request Body:
fileName: users_20Jan
file: /home/desktop/users.xls
Response Code: 201
Operations performed by this API:
- Save import users.xls file to cloud and make entry into the database.
- Read each row of the excel sheet. Check users with the same credentials already exist.
- Set data to object and save to database.
Case 2: I need to insert bulk users using excel(xls) but the excel file is already present on the cloud.
What I implemented:
URL: [POST] {{base_url}}/users/bulk/{{import_file_id}}
Request Body: Empty
Response Code: 201
Operations performed by this API:
- Get a download URL for the file using importFileId from the database.
- Download file from the cloud.
- Read each row of the excel sheet. Check users with the same credentials already exist.
- Set data to object and save to database.
Is there any standardization defined for these types of RestAPI. If not then is there any better way of doing this?
FYI
URL: `{{base_url}}/users` is already being used for single-user and an array of users in the JSON request body.
These all are requirements of the project.