Automating an inventory data feed
Create an inventory data feed to integrate the with an existing inventory solution, and ensure more
accurate inventory data on your storefront and within the . Utilizing the REST API, you can automate file uploads to ensure that the
catalog inventory data within is up-to-date without the need for
manual processes or interventions.
Before you begin
- Ensure that you understand your organization's inventory management system and plan its integration with Inventory management.
- You must automate the generation of catalog and inventory data in the appropriate file format. Review Administering Inventory data uploads for more information on catalog and inventory data.
About this task
Use the Inventory Data Feed API to upload inventory data, obtain that status of previous uploads, and obtain the detailed upload reports to verify or troubleshoot file uploads.
The Inventory Data Feed API endpoint is:
/api/inventory/v1/file-uploads.
The API supports the following operations:
POST- Upload inventory data in bulk to the platform.GET- Get the status of the file upload job.GET- Download the report for the file upload job.
Procedure
-
You can access the REST API using Basic Authentication, which requires
including a valid username and password in the HTTP request headers. This method
ensures that only authorized users or service accounts can interact with the API
endpoints. By default, the username is set to
inventory-data-feed-service-account-user. The password is configured separately for each environment and should be obtained from the administrator. -
Issue a request to the Inventory Data Feed API endpoint, using the access token
as a bearer token.
The following is a sample API call which can be used to upload the inventory data.
curl --location 'https://hostname:11443/inventory/api/v1/file-uploads' \ --header 'Content-Type: multipart/form-data' \ --header 'Authorization: Basic xxxxxx' \ --form 'fileToUpload=@"/C:/GitHub/HCL/github02/commerce-dev/commerce-inventory-service/doc/designs/references/inventory.csv"'The response header location field contains the job ID.
The following is a sample response.https://hostname:11443/inventory/api/v1/file-uploads?jobNumber=1 - Optional:
You can monitor the file upload procedure using the job
ID.
Issue a GET request to the Inventory Data Feed API endpoint with the job ID in the query parameter.
The following is a sample API call which can be used to get the status of the corresponding upload job.curl --location 'https://hostname:11443/inventory/api/v1/file-uploads?jobNumber=1' \ --header 'Authorization: Basic xxxxxx'The response contains the status of the upload job.The following is a sample response.{ "resourceId": "https://hostname:11443/inventory/api/v1/file-uploads?jobNumber=1", "count": 1, "contents": [ { "id": 1, "jobNumber": 1, "fileName": "inventory-sample.csv", "entity": "inventory", "timeStarted": "2024-05-16T21:34:27.968+00:00", "timeCompleted": "2024-05-16T21:34:28.085+00:00", "report": "https://hostname:11443/inventory/api/v1/file-uploads/1", "status": "SUCCESS" } ] } - Optional:
You can review the upload report to confirm your upload was consumed by the
, or examine any errors that were
encountered in full detail.
Issue a GET request to the Inventory Data Feed API endpoint with the job ID in the query parameter.
The following is a sample API call which can be used to download the report for the corresponding upload job.curl --location 'https://hostname:11443/inventory/api/v1/file-uploads/1' \ --header 'Authorization: Basic xxxxxx'The response contains the report.