Fluent Commerce Logo
Docs
Sign In

Category Batch API

Essential knowledge

Author:

Fluent Commerce

Changed on:

3 July 2024

Overview

The Category Batch API is used to create a Category using the Fluent Commerce Batch framework.

Key points

  • Category Batch Properties
  • What you can do with the Category Batch API
  • Respose on Failures


Category Batch API

Overview

The Category Batch API is used to create a Category using the Fluent Commerce Batch framework.

Category Batch Properties

Below are the properties available in the Category Batch object which can be updated/retrieved through the APIs in this document.

1. action

Type: String

Description: The type of operation that will be applied to all records in the batch. Allowed value is UPSERT.


2. entityType

Type: String

Description: Entity type. Allowed values are CATEGORY.


3. entities

Type: Array

Description: An array of category POST records.


4. categoryRef

Type: String

Description: External Category reference to be referenced as parent category.


5. id

Type: DateTime

Description: Unique id associated to the created batch.


6. jobid

Type: String

Description: The unique job id.


7. batchId

Type: String

Description: The unique batch id.


8. start

Type: String

Description: Offset of result.


9. count

Type: DateTime

Description: The count of batches shown.


10. total

Type: String

Description: Total no of batches.


11. status

Type: String

Description: state of the batch:

  • PENDING - Batch has been entered but is not currently running
  • RUNNING - Batch is being processed
  • COMPLETE - Batch has been processed ( with or without errors ) The unique batch id.


12. results

Type: Array Description: Array of Batch Record Status.


13. BATCHRECORDSTATUS

Type: entityId

Description: Fluent Commerce ID of category entity. This field is only available when category is created successfully.


14. Type: entityRef

Type: entityRef

Description: External reference of category entity.


15. Type: responseCode

Type: responseCode

Description:

  • 2
  • 00 OK - successful,
  • 404 - not found ( Dependent record ),
  • 500 - Internal Server,
  • 401 - Unauthorized.


16. Type: message

Type: message

Description: Descriptive message related to the response code.


What you can do with the Category Batch API

Create a new Batch Job

This endpoint can be used to create a new batch

POST: 

`/api/v4.1/job/{jobid}/batch`

Request and response

Request parameters and sample

1batchRequest {
2
3    action (string, compulsory) = UPSERT,
4    entityType (string, compulsory) = CATEGORY,
5    entities (array, compulsory),
6
7
8        CategoryPost {
9            categoryRef (string, compulsory),
10            name (string, compulsory),
11            parentCategoryRef (string, optional),
12        }
13
14}

Language: java

Name: Batch request

Description:

[Warning: empty required content area]
1{
2  "action": "UPSERT",
3  "entityType": "CATEGORY",
4  "entities": [
5    {
6      "categoryRef": "CGR-0001",
7      "name": "Category 001",
8      "parentCategoryRef": "CGR-000"
9    },
10    {
11      "categoryRef": "CGR-0002",
12      "name": "Category 002"
13    }
14  ]
15}

Language: json

Name: Example request

Description:

[Warning: empty required content area]

Response Parameters and sample

1SuccessMessageResponse {
2
3    id (object, optional),
4    message (string, optional),
5    status (string, optional)
6}

Language: java

Name: Batch response

Description:

[Warning: empty required content area]
1{
2 "id":"427323"
3}

Language: json

Name: Example response

Description:

[Warning: empty required content area]
View details of a batch job

This endpoint can be used to view the status of a batch job

GET: 

`//api/v4.1/job/{jobid}/batch/{batchId}`

Request and response

Request parameters and sample

`/api/v4.1/job/223/batch/299`

Response object and sample

Batch response

1batchResponse {
2
3    batchId (string),
4    entityType (string) = 'CATEGORY', 
5    status (string) = 'PENDING', 'RUNNING', 'COMPLETE',
6    start (integer),
7    count (integer),
8    total (integer),
9    results (array[batchRecordStatus]):
10    [{
11    entityId (string),
12    entityRef (string),
13    responseCode (string) = '200', '404', '500', '401'
14    message (string)
15    }]
16}

Language: java

Name: Batch Response Example

Description:

[Warning: empty required content area]

Example Batch task response of 2 categories

1{
2  "batchId": "1",
3  "entityType": "CATEGORY",
4  "status": "PENDING|RUNNING|COMPLETE",
5  "start": 1,
6  "count": 100,
7  "total": 5000,
8  "results": [
9      {
10            "responseCode": 404,
11            "entityRef": "CGR-0001",
12            "message": "Parent category \"CGR-000\" does not exist"
13      },
14      {
15            "responseCode": 200,
16            "entityId": "2",
17            "entityRef": "CGR-0002",
18            "message": "Category update successfully"
19      }
20  ],
21  "createdOn": "2017-09-20T10:00.000Z"
22}

Language: json

Name: Example Batch task response of 2 categories

Description:

[Warning: empty required content area]

Response on Failures

NAME

TYPE

DESCRIPTION

error

Array

Array of errors

message

String

Additional information on the code Unauthorized | Bad Request | Forbidden | Not Found | Status 500 Error

code

String

Status Code for the above messages 401 | 400 | 403 | 404 | 500



Fluent Commerce

Fluent Commerce