Step 1: Run DataMasker from 3rd Party Tools via REST API

*This step is Optional

Overview

Data Masking is a process to mask all sensitive data available in Sandbox which will prevent developers or other users from viewing sensitive data. In the particular use cases where the Data Masking needs to be invoked by an external system, Cloud Compliance offers a REST API interface for masking sensitive data.

This document explains how to invoke Data Masking configurations that are pre-configured via REST API using a JSON-based callout. The API performs data masking of sensitive data in the relevant sandbox whose details are provided in the configuration.

The REST APIs that are developed for this requirement are as follows – 

1.  POST Request: This is the 1st API that is used to execute data masking via REST.

URL

/services/apexrest/pcldm/v1/DataMaskerService

Request Body 

{
    
    "dataMaskingRequest": {
        
        "maskingId": "cff536a0adbf672d982a4136088fbe9e"
    }
}

2. POST Request: This is the second API that is used to retrieve the Status of masking after the execution is completed.

URL

/services/apexrest/pcldm/v1/FetchMaskingStatus

Request Body 

{
    "dataMaskingRequest": {
        "executionId": "a043h00000QvyytAAB"
    }
}

Solution Steps
 

1. Navigate->Configurations tab of the Data Masker application.

21.png

2.Click on the Configuration name. In this case, click on ‘UAT sandbox’. 

22.png

3. Copy the Configuration id and paste this id into the REST script that needs to be executed for data masking.

23.png

 4. Navigate-> REST tool such as Salesforce developer workbench, Postman, Insomnia, etc. (This example uses Salesforce Developer Workbench) https://workbench.developerforce.com/restExplorer.php 

24.PNG

5. Navigate-> ‘REST Explorer’  from the Utility tab  within the workbench and select the “POST” method

25.png

6. For the “POST” method, enter the DataMaskerService REST call URL

             
/services/apexrest/pcldm/v1/DataMaskerService  

7. Copy the Configuration id and paste it in the following JSON format of the request body.

{
    "dataMaskingRequest": {
        "maskingId": "58dbdf18d60675f69638b45445556f8b"
    }
}
26.png


8. Click the “Execute” button to invoke the REST API

27.png

9. The REST API returns a Success status as True or False and the execution Id. 

28.png

10. Use the 2nd REST API to get the execution status. Copy the execution id retrieved from the First API call and pass it to the second API to get the execution details. Again this is the POST method used to fetch the details.

URL


/services/apexrest/pcldm/v1/FetchMaskingStatus 

Request Body 

{
    "dataMaskingRequest": {
        "executionId": "a045j000008VCN0AAO"
    }
}
29.png


11. Click on Execute to get the execution details. The attributes extracted from this REST API call out are as follows –

  • status: true
  • isProcessCompleted: true
  • execution
30.png

12. The detail raw response is as follows:

HTTP / 1.1 200 OK
Date: Fri, 04 Mar 2022 11: 35: 36 GMT
Set - Cookie: CookieConsentPolicy = 0: 1;
path = /;
expires = Sat, 04 - Mar - 2023 11: 35: 36 GMT;
Max - Age = 31536000 Set - Cookie: LSKey - c$CookieConsentPolicy = 0: 1;
path = /;
expires = Sat, 04 - Mar - 2023 11: 35: 36 GMT;
Max - Age = 31536000 Strict - Transport - Security: max - age = 63072000;
includeSubDomains X - Content - Type - Options: nosniff X - XSS - Protection: 1;
mode = block X - Robots - Tag: none Cache - Control: no - cache, must - revalidate, max - age = 0, no - store,
    private Set - Cookie: BrowserId = NbheW5uvEey1zs2_8w2v5Q;
domain = .salesforce.com;
path = /;
expires = Sat, 04 - Mar - 2023 11: 35: 36 GMT;
Max - Age = 31536000 Content - Type: application / json Vary: Accept - Encoding Content - Encoding: gzip Transfer - Encoding: chunked {
    "status": true,
    "isProcessCompleted": true,
    "execution": {
        "sfId": "a045j000008VCN0AAO",
        "recordUrl": "https://pcl-af-dev-ed.my.salesforce.com/a045j000008VCN0AAO"
        ",
        "recordsTotal": 23,
        "recordsProcessed": 23,
        "recordsErrored": 0,
        "maskingStatus": "Completed",
        "executionType": "All"
    }
}

Powered by BetterDocs