Invalidate Affected Response API

The Invalidate Affected Response API invalidates the cache entries that have become inaccurate due to catalog offer changes. You must pass the cachedAPIResponseIds provided in the invalidateAction node received in the response from the Affected Cache API.

You can obtain the List<cachedAPIChangeIds> or cachedAPIChangeIds required in the request body of this API from the cachedAPIChangeIds node (records.invalidateAction.invalidateCachedResponse.rest.requestBody.cachedAPIResponseIds) in the response body of the Get Affected Cache API.

URI 

/services/apexrest/vlocity_cmt/v3/admin/catalogs/regenerate/invalidate

HTTP Method 

POST

URL Parameters 

For example: POST /services/apexrest/vlocity_cmt/v3/admin/catalogs/regenerate/invalidate?expirationTime=2021-08-24T12:08:56

ParameterExampleDefaultOptional/RequiredDescription
expirationTime2021-08-24T12:08:56NullOptionalFor the future dated cache. The format is YYYY-MM-DDThh:mm:ss

Request Body Parameters 

ParameterData TypeDescriptionOptional/Required
cachedAPIResponseIdsStringcachedAPIResponse Ids that are invalid due to catalog offer changes.Required

Sample Input 

cachedAPIChangeIds contain the IDs of the cached API response objects, which could consist of a list of changes.

This is sample input for the ID of the cachedAPIResponse object.

1{
2    "cachedAPIResponseIds": [
3        "a0a5g000000Dn6pAAC",
4        "a0a5g000000Doj4AAC",
5        "a0a5g000000DoJVAA0",
6        "a0a5g000000DpBjAAK",
7        "a0a5g000000DpG7AAK"
8    ]
9}

Sample Input for invalidateAction Node 

1{
2      "invalidateAction": {
3        "invalidateCachedResponse": {
4          "rest": {
5            "requestBody": {
6              "cachedAPIResponseIds": [
7                "a0a5g0000005JbKAAU",
8                "a0a5g0000005JaGAAU",
9                "a0a5g0000005JbTAAU",
10                "a0a5g0000005JbUAAU",
11                "a0a5g0000005JbVAAU",
12                "a0a5g0000005JbWAAU"
13              ]
14            },
15            "params": {
16
17            },
18            "link": "/v3/admin/catalogs/regenerate/invalidate",
19            "method": "POST"
20          }
21        }
22      }
23    }

HTTP Headers 

HeaderDescription
Content-Typeapplication/json

Remote API 

This is an example of how you invoke the API using Apex:

1String methodName;
2Map<String, Object> input = new Map<String, Object>();
3Map<String, Object> output = new Map<String, Object>();
4Map<String, Object> options = new Map<String, Object>();
5// Setting remote parameters
6methodName = 'invalidateCachedAPIResponse';
7input.put('methodName',methodName);//required
8input.put('apiName','regenerate'); //requires
9List<Id> cachedAPIResponseIds = new List<Id>();
10cachedAPIResponseIds.add('a4Q5g000000TmnaEAC');
11input.put('cachedAPIResponseIds',cachedAPIChangeMap); //required
12//remote action invocation
13jk_232_cam.CpqAppHandler appHandler = new jk_232_cam.CpqAppHandler();
14appHandler.invokeMethod(methodName, input, output, options);

Parallel Invocation 

You can run this API in parallel for different cachedAPIResponseIds. For example, if there are 100 invalidate Action nodes from the GetAffected cache API (INVALID_ACTION1, INVALID_ACTION 2…INVALID_ACTION100) and each action node contains a list of cachedAPIResponseIds, such as INVALID_ACTION1.CAR1, then you can run parallel threads of Invalidate APIs with each individual invalidate Action node.

1THREAD1 -  POST /services/apexrest/vlocity_cmt/v3/admin/catalogs/regenerate/invalidate
2           Body : {"cachedAPIResponseIds":INVALID_ACTION1.CAR1}
3THREAD2 -  POST /services/apexrest/vlocity_cmt/v3/admin/catalogs/regenerate/invalidate
4           Body : {"cachedAPIResponseIds":INVALID_ACTION2.CAR2}
5THREAD3 -  POST /services/apexrest/vlocity_cmt/v3/admin/catalogs/regenerate/invalidate
6           Body : {"cachedAPIResponseIds":INVALID_ACTION3.CAR3}
7.
8.
9.
10.
11THREAD100 -  POST /services/apexrest/vlocity_cmt/v3/admin/catalogs/regenerate/invalidate
12            Body : {"cachedAPIResponseIds":INVALID_ACTION4.CAR100}

Response Body 

The return status indicates success or failure with a reason for the error. For example:

1{
2    "message": "Successfully completed.",
3    "errorCode": "INVOKE-200",
4    "error": "OK"
5}

HTTP Response Codes 

CodeDescription
200OK
500Internal Server Error