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

Parameter Example Default Optional/Required Description
expirationTime 2021-08-24T12:08:56 Null Optional For the future dated cache. The format is YYYY-MM-DDThh:mm:ss

Request Body Parameters

Parameter Data Type Description Optional/Required
cachedAPIResponseIds String cachedAPIResponse 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.

{
    "cachedAPIResponseIds": [
        "a0a5g000000Dn6pAAC",
        "a0a5g000000Doj4AAC",
        "a0a5g000000DoJVAA0",
        "a0a5g000000DpBjAAK",
        "a0a5g000000DpG7AAK"
    ]
}

Sample Input for invalidateAction Node

{
      "invalidateAction": {
        "invalidateCachedResponse": {
          "rest": {
            "requestBody": {
              "cachedAPIResponseIds": [
                "a0a5g0000005JbKAAU",
                "a0a5g0000005JaGAAU",
                "a0a5g0000005JbTAAU",
                "a0a5g0000005JbUAAU",
                "a0a5g0000005JbVAAU",
                "a0a5g0000005JbWAAU"
              ]
            },
            "params": {

            },
            "link": "/v3/admin/catalogs/regenerate/invalidate",
            "method": "POST"
          }
        }
      }
    }

HTTP Headers

Header Description
Content-Type application/json

Remote API

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

String methodName;
Map<String, Object> input = new Map<String, Object>();
Map<String, Object> output = new Map<String, Object>();
Map<String, Object> options = new Map<String, Object>();
// Setting remote parameters
methodName = 'invalidateCachedAPIResponse';
input.put('methodName',methodName);//required
input.put('apiName','regenerate'); //requires
List<Id> cachedAPIResponseIds = new List<Id>();
cachedAPIResponseIds.add('a4Q5g000000TmnaEAC');
input.put('cachedAPIResponseIds',cachedAPIChangeMap); //required
//remote action invocation
jk_232_cam.CpqAppHandler appHandler = new jk_232_cam.CpqAppHandler();
appHandler.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.

THREAD1 -  POST /services/apexrest/vlocity_cmt/v3/admin/catalogs/regenerate/invalidate
           Body : {"cachedAPIResponseIds":INVALID_ACTION1.CAR1}
THREAD2 -  POST /services/apexrest/vlocity_cmt/v3/admin/catalogs/regenerate/invalidate
           Body : {"cachedAPIResponseIds":INVALID_ACTION2.CAR2}
THREAD3 -  POST /services/apexrest/vlocity_cmt/v3/admin/catalogs/regenerate/invalidate
           Body : {"cachedAPIResponseIds":INVALID_ACTION3.CAR3}
.
.
.
.
THREAD100 -  POST /services/apexrest/vlocity_cmt/v3/admin/catalogs/regenerate/invalidate
            Body : {"cachedAPIResponseIds":INVALID_ACTION4.CAR100}

Response Body

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

{
    "message": "Successfully completed.",
    "errorCode": "INVOKE-200",
    "error": "OK"
}

HTTP Response Codes

Code Description
200 OK
500 Internal Server Error