How do I use the PBRS API to execute Schedules?

The PBRS API allows you to run schedules as well as control the scheduling services. You can use any programming language of your choice to query the API.

You must install PBRS API in order to execute Schedules using PBRS API - Click here.

Executing Schedule using PBRS API

The PBRS API allows you to run schedules as well as control the scheduling services. You can use any programming language of your choice to query the API.

The API is accessed by making HTTP requests to a specific URL endpoint, in which GET or POST variables contain information about what you wish to access. Every endpoint is accessed via the port and protocol configured in PBRS. The PBRS API Service must also be running on the PBRS server.

The default starting endpoint for the API is:

http://[pbrsserver]:9000/api

 

Service Endpoint

The Service Endpoint allows you to query and control the PBRS services.

Ping

To check if the API is up and running, you can use Ping. The call will return 1 when the API is running

GET /api/service/ping

Result:

int i

IsSchedulerRunning

To check if the PBRS scheduler is running:

GET /api/service/isschedulerrunning

Result:

bool Result

GetConfigPath

To get the patch to the PBRS config file:

GET /api/service/getconfigpath

Result:

string Result

UpdateCollaborationSettings

To update the collaboration settings for a server:

POST /api/service/updatecollaborationsettings

POST Body:

bool IsCollaborationEnabled 

int CollaborationId

string CollaborationLeader

string ConType

string ConString

string ConString2

 

Schedule Endpoint

The Schedule endpoint allows you to control PBRS schedules. Where a schedule type must be specified, the following are valid:

  •  "report" or “single”: all Single and Data-Driven Schedules               

  • "automation": all Automation schedules

  • "package": all Single and Data-Driven Package schedules

  • "event": all Event-Based schedules

  • event-package" or “eventpackage”: all Event-Based Package schedules

The schedule’s unique Id can be obtained from the schedule’s properties screen in the application GUI.

ExecuteSchedule

Synchronously kicks off a schedule and waits for its completion.

POST api/schedule/executeschedule

POST Body:

string ScheduleType 

int UniqueueId

string RunBy

Result:

bool Result 

string ErrorMessage

int ErrorNumber

ExecuteScheduleOnTimeAsync

Asynchronously kicks off the schedule as if it is being run by the scheduler. At completion, the schedule’s NextRun date will be incremented.

POST api/schedule/executescheduleontimeasync

POST Body:

string ScheduleType 

int UniqueueId

string RunBy

Result:

string ExecutionId

ExecuteScheduleAsync

Asynchronously kicks off a schedule and does not wait for its completion. The resulting ExecutionId can be used to query the execution status.

POST api/schedule/executescheduleasync

POST Body:

string ScheduleType 

int UniqueueId

string RunBy

Result:

string ExecutionId

GetNumberOfFreeThreads

Gets the number of threads that are available for schedule execution based on the configured maximum thread count set in the application.

GET api/schedule/getnumberoffreethreads

Result:

int Result

CancelExecution

Attempts to cancel an existing async execution.

GET api/schedule/cancelexecution?ExecutionId={ExecutionId}

Result:

string Result

GetExecutionStatus

Retrieves the status of a schedule execution. The status can be one of:

  • Waiting

  • Executing

  • Completed

GET api/schedule/GetExecutionStatus?ExecutionId={ExecutionId}

Result:

string ExecutionId 

int UniqueueId

int ProcessId

string Status

long EntryDateEpoch

long CompletionDateEpoch

string RunBy

string ResultJson*

string ServerName

*ResultJson Format:

bool success 

string errormessage