|
<< Click to Display Table of Contents >> Raynet One Data Hub > 2026.2 > Administration and User Guide > Tasks > Executing Tasks Using Offline Agents Importing Task Results via REST API |
In addition to the interactive import wizard, task results produced by an offline agent can be submitted programmatically using the POST /v1/Agent/offline/import endpoint. This approach is suitable for scripted or automated workflows, such as pipelines running in DMZ environments, where manual interaction with the Data Hub user interface is not practical.
The endpoint accepts the same result ZIP file that the offline agent produces and applies the identical import logic as the UI wizard. All task metadata — including original start and end times, execution logs, and result table counts — is fully preserved. The imported data is written to the result database in the same way as an online task execution.
•An API key for a Data Hub user account that belongs to the target tenant. API keys are managed on the API Keys tab of the user Profile page. See Authentication and Authorization for step-by-step instructions.
•The result ZIP file generated by the offline agent after task execution. This file is located in the Output folder of the agent installation directory.
•An offline connector configured in Data Hub with both a public key (Agent Public Key) and a private key (Server Private Key) set. These keys are used to decrypt the result ZIP during import.
POST
<serverUrl>/v1/Agent/offline/import
Header |
Required |
Description |
|---|---|---|
ApiKey |
Yes |
API key used to authenticate the request. The key must belong to a user account within the target tenant. See Authentication and Authorization for instructions on creating and managing API keys. |
The request must use multipart/form-data encoding. Include one or more result ZIP files in the form field named taskResultFiles. Multiple files can be submitted in a single request; each file is imported independently and produces a separate entry in the response.
Field Name |
Required |
Description |
|---|---|---|
taskResultFiles |
Yes |
One or more result ZIP files produced by the offline agent. Each file is typically located in the Output folder of the agent installation directory after task execution completes. The maximum total request size is 100 GB. |
Status Code |
Description |
|---|---|
200 OK |
All submitted files were accepted for processing. The response body contains a JSON array with one entry per submitted file. Check the success field in each entry to confirm whether the individual file was imported without errors. |
400 Bad Request |
The request is invalid. Common causes: no files were provided in the taskResultFiles field, or tenant or user context is missing. |
401 Unauthorized |
The ApiKey header is missing or the provided API key is invalid. |
A successful response (HTTP 200) returns a JSON array. Each element corresponds to one submitted ZIP file and contains the following fields:
Field |
Type |
Description |
|---|---|---|
zipFileName |
string |
The file name of the submitted ZIP file. |
taskName |
string |
The display name of the task that produced the results. |
tableCount |
integer |
The number of result tables found in the submitted ZIP file. |
success |
boolean |
Indicates whether the file was imported without errors. A value of true means the import was queued successfully. A value of false indicates an error; see the errorMessage field for details. |
errorMessage |
string |
Populated only when success is false. Contains an error code that identifies the reason for failure. Possible values: DECRYPTION_ERROR (the ZIP file could not be decrypted), INVALID_METADATA (the metadata inside the ZIP is missing or malformed), TASK_NOT_FOUND (the task referenced in the metadata does not exist), WRONG_TENANT (the task belongs to a different tenant), COLLECTOR_NOT_LICENSED (the collector type is not licensed), IMPORT_ERROR (an unexpected error occurred during import). |
taskHistoryId |
GUID |
The unique identifier of the task history entry created during the import. This value is populated only when success is true. Use this ID to look up the import result in the Task History view. |
The following examples demonstrate how to call the import endpoint from a script. Replace <server> with the hostname or IP address of your Data Hub server and <YOUR_API_KEY> with a valid API key for a user in the target tenant.
The following command sends a single result ZIP file to the import endpoint:
Invoke-RestMethod `
-Uri "https://<server>/v1/Agent/offline/import" `
-Method POST `
-Headers @{ "ApiKey" = "<YOUR_API_KEY>" } `
-Form @{ taskResultFiles = Get-Item ".\result.zip" }
The command parameters work as follows:
•-Uri — The full URL of the import endpoint. Replace <server> with the hostname or IP address of your Data Hub server.
•-Method POST — Specifies the HTTP method. The import endpoint requires a POST request.
•-Headers @{ "ApiKey" = "<YOUR_API_KEY>" } — Passes the API key in the ApiKey request header. Replace <YOUR_API_KEY> with the key value from your user profile.
•-Form @{ taskResultFiles = Get-Item ".\result.zip" } — Sends the file as a multipart/form-data upload. The form field name must be taskResultFiles. Get-Item returns a FileInfo object, which PowerShell automatically converts into a file upload. Adjust the path to match the actual location of the result ZIP file.
curl -X POST "https://<server>/v1/Agent/offline/import" \
-H "ApiKey: <YOUR_API_KEY>" \
-F "taskResultFiles=@result.zip"
•Authentication and Authorization
•Executing Tasks Using Offline Agents