Worker for Generic Event

JFrog REST APIs

Content Type
REST API
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.73.1

Security: Admin authentication is required.

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.

projectKey

string

No

If set, this Worker will be available in the scope of the given project (editable by platform admin and project admin). If not set, this Worker will be global and only editable by the platform admin.

If set, this Worker will be available in the scope of the given project (editable by platform admin and project admin). Otherwise this Worker will be global and only editable by platform admin. Once set, the projectKey cannot be changed.

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.