Worker for Generic Event

JFrog REST APIs

ft:sourceType
Paligo

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.

Since: 7.7x.x

Security: Admin authentication is required.

Usage: POST /worker/api/v1/execute/{workerKey}

Produces: application/json; charset=utf-8

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.