API v1 - Shared Jobs

API v1 - Shared Jobs

This article belongs to series on Shared Jobs and on v1 API.

The sharedjob endpoint allows users to explore what Shared Jobs are available on the instance as well as importing, exporting and deleting them. Users wanting to make use of this endpoint will require an account with the API Role and Shared Jobs permissions.


Exploring Packages, Jobs and Revisions

List all packages

curl -X GET -u username:password http://<InstanceAddress>/rest/v1/sharedjob/package/

Go into a specific package

curl -X GET -u username:password http://<InstanceAddress>/rest/v1/sharedjob/package/name/<PackageName>

From here you can list jobs inside the package

curl -X GET -u username:password http://<InstanceAddress>/rest/v1/sharedjob/package/name/<PackageName>/job

And the revisions of that job

curl -X GET -u username:password http://<InstanceAddress>/rest/v1/sharedjob/package/name/<PackageName>/job/name/<JobName>/revision


Export all Packages, Shared Jobs and Revisions

curl -X GET -u username:password http://<InstanceAddress>/rest/v1/sharedjob/export

Export Package with all Jobs and Revisions it includes.

curl -X GET -o output.json -u username:password http://<InstanceAddress>/rest/v1/sharedjob/package/name/<PackageName>/export 

Export Job with all Revisions it includes

curl -X GET -o output.json -u username:password http://<InstanceAddress>/rest/v1/sharedjob/package/name/<PackageName>/job/name/<JobName>/export

Export Revision

curl -X GET -o output.json -u username:password http://<InstanceAddress>/rest/v1/sharedjob/package/name/<PackageName>/job/name/<JobName>/revision/id/<RevisionID>/export

Exporting a package will get all jobs and all their revisions. Exporting a job will get all revisions of that job. Exporting a revision gets just one SharedJob of that specific revision.



Imports all shared jobs from a JSON. Attempts each individually and reports on their success/failure. This can be used with the JSONs gained through any level of exporting.

curl -X POST http://<instance_address>/rest/v1/sharedjob/import -H "Content-Type: application/json" --data-binary "@sharedjobs.json"

As a response, for a successful import you will get:

"success" : true,
"name" : <sharedjobname>

Or a for a failed response:

"success" : false,
"name" : <sharedjobname>,
"exception" : "com.matillion.bi.emerald.server.rest.v1.exception.RestAPIException",
"msg" : <error message>

The error message will display the reasoning for the failed import. For example, Jobs will fail to import if there is already a job of the same name. However, this does not prevent other job imports from succeeding.



Packages, Jobs and Revisions can be deleted via the API

Delete a specific package:

curl -X POST -u username:password http://<InstanceAddress>/rest/v1/sharedjob/package/name/<PackageName>/delete

Delete a specific Shared Job:

curl -X POST -u username:password http://<InstanceAddress>/rest/v1/sharedjob/package/name/<PackageName>/job/name/<JobName>/delete

Delete a specific Revision:

curl -X POST -u username:password  http://<InstanceAddress>/rest/v1/sharedjob/package/name/<PackageName>/job/name/JobName/revision/id/<RevisionID>/delete