简体   繁体   中英

Bulk Create/Update API where client is unaware of create or update

Use Case: User receives CSV file from Supplier about the inventory which needs to be fed into the user's e-commerce website/backend. The CSV could contain inventory items that were previously uploaded. CSV contains the item attributes sent by the Supplier and does not contain the item-id which is specific to the e-commerce backend system.

This is a case where the backend system goes through each item in the CSV, decides if it is a Create case or Update case (based on 5 attributes of the item), and makes the changes accordingly.

How do we design a RESTful API for each use case?

This sounds like an "import".

I'd make a single API method called "Import Inventory" (eg, POST /inventory:import ) where the CSV is provided as input and the result is a summary of what items were created/updated.

Some references worth looking at:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM