Retrieving checksums through REST API

Available from 9.2.3. To retrieve information about checksums, you can use REST API that is generally used to retrieve raw scanned file data. This API retrieves information about scanned files, such as name, size, version, path, and so on. It can also return the values of the MD5 and SHA-256 columns, which show the checksums.

Before you begin

This topic is only an excerpt from the REST API call, intended to show specific examples that can be used to retrieve the MD5 and SHA-256 checksums. For more information, see REST API for retrieving raw scanned file data.

Sample columns

The following response body shows default columns that can be retrieved by using this REST API. You can use the names of the shown columns while creating your REST API requests. If you do not specify any columns in the request, all of them are returned.
 {
  "scan_file_id": 3,
  "computer_id": 5,
  "path": "C:\BES\BESAirgapTool",
  "name": "BESAirgapTool.exe",
  "full_path_sha1": "9eb46086883dcbb6d2aefa2d6fd40bf8e736621b",
  "size": 92174,
  "version": null,
  "md5": "8cb2289800b34ef1a5f472f7177348e2",
  "sha256": "99e0c7c22c9ad735ec766914f0af17449a83681de22db7ce16672f16f37131bec0022371d4ace5d1854301e0",
  "valid_from": "2015-07-31T07:03:21Z"
  "valid_to": "9999-12-31T23:59:59Z"
 }

Examples

Example 1: Retrieving information only about name, computer name, path, MD5, and SHA-256 columns.
Request:
https://hostname:port/api/sam/raw_file_facts?token=token
&columns[]=name&columns[]=computer.name&columns[]=path&columns[]=md5&columns[]=sha256
Output:
 {
  "path": "C:\BES\BESAirgapTool",
  "name": "BESAirgapTool.exe",
  "md5": "8cb2289800b34ef1a5f472f7177348e2",
  "sha256": "99e0c7c22c9ad735ec766914f0af17449a83681de22db7ce16672f16f37131bec0022371d4ace5d1854301e0",
  "computer":{
     "name":"NC581058"}
 }
Example 2: Retrieving information about files with a specific MD5 checksum.

This example can be used to quickly find a corrupted checksum.

Request:
https://hostname:port/api/sam/raw_file_facts?token=token
&criteria={"and":[["md5","=","8CB2289800B34EF1A5F472F7177348E2"]]}
Output:
 {
  "scan_file_id": "6",
  "computer_id": "3",
  "path": "C:\Files",
  "name": "arch.exe",
  "full_path_sha1": "9eb46086883dcbb6d2aefa2d6fd40bf8e736621b",
  "size": 2032,
  "version": null,
  "md5": "8cb2289800b34ef1a5f472f7177348e2",
  "sha256": null,
  "valid_from": "2015-12-10T11:37:14Z",
  "valid_to": "9999-12-31T23:59:59Z"
 } 
Example 3: Retrieving information about name, computer name, path, and MD5 columns for all word.exe files that have a different MD5 checksum than the specified one.

This example can be used if you know that a file should have a specific checksum. You can therefore retrieve all files with other, corrupted checksums.

Request:
https://hostname:port/api/sam/raw_file_facts?token=token
&columns[]=name&columns[]=computer.name&columns[]=path&columns[]=md5
&criteria={"and":[["md5","!=","8CB2289800B34EF1A5F472F7177348E2"],["name","=","word.exe"]]}
Output:
 {
   "path": "C:\Programs",
   "name": "word.exe",
   "md5": "6cb1465800b34ef1a5f376f717743t6",
   "computer":{
      "name":"NC581058"}
 }