Batch management

General info about batch management in the Public API

A batch is initiated through a batch job request call to the endpoint postJob, whereupon a correlation id (guid) is obtained. This id can then be used to poll the status of the job with a call to the jobStatus endpoint. When the jobStatus endpoint returns a 'completed' status or a 'completedWithErrors' status, the job is processed. In the latter case, at least one error was found in the batch, and a list of the entity id:s where errors where detected along with error messages are included in the return message from the endpoint.

Code of Conduct

  • A user of the Genero Solutions Public API Batch management should only have one batch job active at a time.
  • The batch management functionality with max sized batches, meaning a full registry update of all entitites, is to be used at most once a week. Smaller batch jobs can be used more often.
  • Genero Solutions has the right to remove access to the Public API for any user that does not follow the described Code of Conduct.

Multi tenant batch requests

To apply a batch on multiple tenant with one call, use the multitenant batch endpoint. This require an api key configured for multi tenant agency, please contact the Genero helpdesk to aquire such an api key.

The post request will return a response (with http code 200) containing a dictionary of tenants and correlation keys for all successfull posts. If any tenant given in the list of tenants enounters a problem, a partial success (http code 207) will be returned. After posting a multitenant batch, call for status for each tenant separately using the correlation key returned for each successfully posted tenant.

Example multi tenant partial success result

The following json represents a request-response sequence when one of the tenants is unrecognized.

Request

{ "generoTenantIds": [ "publicapitest", "publicapitestWRONG" ], "data": [ { "blockId": "blockId1", "name": "Batch TEST block 1", "deleted": false }, { "blockId": "blockId2", "name": "Batch TEST block 2", "deleted": false } ] }

Response

{ "postedSuccess": { "publicapitest": "6df8d937-129b-44ed-9bf2-740717f134a7" }, "postedProblems": { "publicapitestWRONG": [ "Unable to find tenant by identifier: publicapitestWRONG." ] } }

Batch execution order - Customer Domain

  • Block
  • Chain
  • Wholesaler
  • Customer

A batch job request is denied if:

  • an entity in the request is non-unique (for example if the same Block entity is repetedly provided in a batch job request for blocks)
  • the list of entities in the request is empty or exceeds NoOfItems (see General info)
  • the list contains entitites that the API can not interpret

Follow up status on a batch job

We advice you to follow up the status on a batch job request each 5 minutes and conclude the status polling once either of the two 'completed' statuses has been returned. If the job is still shows the status 'In Progress'' after 30 minutes, consider the job timed out and try re-posting the job.

Batch job statuses

Code Description
InProgress Batch job request is received and in progress.
Completed Batch job has completed with no errors.
CompletedWithErrors Batch job has completed with at least one error.

Examples

{ "correlationId": "e08434ee-a17f-445e-b9b5-e25fc354d840", "batchJobStatus": "InProgress", "noOfItemsPosted": 200, "noOfItemsProcessed": 0, "jobItemErrors": {} } { "correlationId": "e08434ee-a17f-445e-b9b5-e25fc354d840", "batchJobStatus": "Completed", "noOfItemsPosted": 200, "noOfItemsProcessed": 200, "jobItemErrors": {} } { "correlationId": "7c3c05ee-444f-4966-b368-9f8417baf6fb", "batchJobStatus": "CompletedWithErrors", "noOfItemsPosted": 200, "noOfItemsProcessed": 200, "jobItemErrors": { "1": "Block id 3 is not found in database." } }