Description: Executes a worker service of type GENERIC_EVENT.
Note
The request body is optional, but must be a valid JSON structure. The request will be injected in the worker script as the second parameter.
The API can retrieve a status when the executionStatus property is included in the request body.
The response body will include the worker return value set under the data property. The executionStatus property will reflect the execution status and contain either STATUS_SUCCESS or STATUS_FAIL.
Since: 7.73.1
Security: Platform Admin, Project Admin (must be project admin for the project key defined in the Worker) or any user (if the worker is shared).
Usage: POST /worker/api/v1/execute/{workerKey}
Produces: application/json; charset=utf-8
Header parameter: Authorization: Bearer
Parameters
Parameter | Datatype | Mandatory | Description |
---|---|---|---|
workerKey | string | Yes | The unique ID of the worker. The worker service must be of type GENERIC_EVENT. |
Sample Worker
Let's look at a sample worker named my-worker that is enabled:
type CustomPayload = any; type CustomResponse = any; export default async (context: PlatformContext, data: CustomPayload): Promise<CustomResponse> => { return data; }
Example 1
Sample Usage 1
curl -XPOST --location 'https://<JFrogPlatform>/worker/api/v1/execute/my-worker \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer <MY-TOKEN>' \ --data '{ "foo": "bar" }
Sample Response 1
{ "data": { "foo": "bar" }, "executionStatus": "STATUS_SUCCESS" }
Example 2
Sample Usage 2
curl -XPOST --location 'https://<JFrogPlatform>/worker/api/v1/execute/my-worker \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer <MY-TOKEN>'
Sample Response 2
{ "executionStatus": "STATUS_SUCCESS" }
Success Response Codes:
200: OK response. The worker was successfully executed.
Error Response Codes:
400 The request payload is malformed.
401 Invalid credentials.
403 Insufficient permissions.
404 The worker does not exist.