The curl command can be used to call the preceding Apex REST API. Locate a Driver record without the FIA Super License field selected and note the record ID. First, run the following sfdx command to obtain an authorization token and install the URL for the current scratch org. Sample output is shown after the command to run:
sfdx force:org:display
Access Token 00D0m0000....MwwyTx
Alias lightningplatformenterprisearchitecturethirdedition
Client Id PlatformCLI
Created By [email protected]
Created Date 2019-06-15T19:53:24.000+0000
Dev Hub Id [email protected]
Edition Developer
Expiration Date 2019-06-22
Id 00D0m000000DXwNEAW
Instance Url https://dream-saas-9403-dev-ed.cs65.my.salesforce.com/
Org Name FormulaForce App Development
Status Active
Username [email protected]
The Access Token shown here has been shortened. Next, we will use the curl command to invoke the Apex REST API created here. You will also need to reference the Instance Url value.
Enter the following command all on one line in the command line, replacing InstallURL and AccessToken with the values output from the previous sfdx command:
curl InstallURL/apexrest/fforce/compliance
-H 'Authorization: Bearer AccessToken'
-H 'Content-Type: application/json'
-d '{ "Ids" : [ "a020m000001piX7AAI" ] }'
-X POST
This command should output the following JSON response:
[{"recordId":"a020m000001piX7AAI","passed":false,"failureReason":"Driver must have a FIA Super License.","complianceCode":"4.1"}]
If you are having problems getting the previous example curl command to work, consult the Salesforce documentation at https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/quickstart.htm?search_text=curl.