Download a File
Endpoint URL: https://<your server>/rest/fetchfile/getfiles/:batchId
Endpoint URI: fetchfile/getfiles/:batchId
Action: GET
Downloads the actual file to your machine. You must also send a request to:
Start the file download. For details on this request, see Start a File Download Operation.
Get the operation batch number for the file download. For details on this request, see Get a Download Batch Number.
Note
Before running this request, ensure that you have logged into the Cybereason platform. For details, see Log in with the API.
Note
This request performs a live file download operation and will only successfully work on currently online machines.
Request Headers
You must add an Content-Type:application/json header with the request.
Note
If you are using cURL, add the authorization cookie details or the path to the file with cookie details with every request.
Request Body
None
Request Parameters
URL/URI parameters: none
Request Body Parameters: none
Response Status Codes
This request can return the following status codes:
200: Success OK
Response Success Schema
The response can contain any of the following fields:
Field |
Type |
Description |
---|---|---|
data |
Boolean |
Indicates whether there is a response. |
status |
Enum |
The status of the file download start operation. Possible values include:
|
message |
String |
The message received from the server about this operation. |
Response Failure Schema
None
Important Response Fields
Important information is found in these fields:
status parameter: This field shows whether the download operation succeeded.
Example: Download a file
Request
curl --request GET \ --url https://12.34.56.78/rest/fetchfile/getfiles/1638177597 \ --header 'Content-Type:application/json' \
Response
File downloads as binary code - save the file using your REST API client
Request
Depending on your browser settings, this linked file may open in a separate tab instead of downloading directly to your machine. If this happens, use the Save As option in your browser to save the file locally.
import requests
import json
# Login information
username = "[email protected]"
password = "mypassword"
server = "myserver.com"
port = "443"
data = {
"username": username,
"password": password
}
headers = {"Content-Type": "application/json"}
base_url = "https://" + server + ":" + port
login_url = base_url + "/login.html"
session = requests.session()
login_response = session.post(login_url, data=data, verify=True)
print (login_response.status_code)
print (session.cookies.items())
# Request URL
batch_id = -1258677756
endpoint_url = "/rest/fetchfile/getfiles/" + str(batch_id)
api_url = base_url + endpoint_url
api_headers = {'Content-Type':'application/json'}
api_response = session.request("GET", api_url, headers=api_headers)
with open('download_file.zip', 'wb') as f:
f.write(api_response.content)
Response
File downloads to selected location.