ArcGIS Enterprise

Schedule a Geoprocessing Service Using the Sharing API

With the latest ArcGIS Enterprise 11.2 or later, you can schedule a geoprocessing service published to your ArcGIS Enterprise using the sharing API by creating a task.

Before creating a task, you must ensure your geoprocessing service is published to an ArcGIS Server federated to a Portal for ArcGIS. Only the portal administrator and web tool item owner can schedule a task on that geoprocessing service. Scheduling a task for a geoprocessing service on a stand-alone ArcGIS Server is not possible. You can not schedule any geoprocessing service to run outside of your federated server either, even though those geoprocessing services may be public. If you are using a custom role when accessing your portal, you must ensure you have at least Publish hosted feature layers, Create, update, and delete an item, and Standard feature analysis privileges of your role.

This blog will walk through createTask, list all current tasks, and other task operations like disable a task from the sharing API for a geoprocessing service. To find the geoprocessing service URL of a web tool item in ArcGIS Enterprise, go to the item details page and the service URL is on the bottom right of the page. Note, you must use the task name URL for the createTask operation, which can be obtained by clicking the task you want to schedule. A sample task URL should follow the pattern as task.

Create a task for a geoprocessing service

To create a task in the sharing API for an existing geoprocessing service, you first need to log in to the sharing API at the sharing REST root. Once logged in, you should be on the user page. From there, you can see the Create Task operation in the list of supported operations. Alternatively, you can go to the direct link as createTask indicates.

You can provide a unique title for anything you see fit.

You must provide GPService, which is case-sensitive.

You must provide a task URL which follows the convention as task. Scheduling a system geoprocessing service, like the spatial analysis tools, is also possible, but you must be a portal administrator to do that.

For example, https://machine.domain.com/webadaptor/rest/services/Network/ESRI_DriveTime_US/GPServer/CreateDriveTimePolygons

All the parameters you want to provide for your geoprocessing service, in the format of a JSON.

For example, my geoprocessing is a simple buffer tool, and I have an input feature parameter and a buffer distance parameter, along with the optional output feature service name automatically added during the publishing process. To create a task with these parameters, I will specify the following, with my output feature service parameter overwriting an existing hosted feature layer that I own.

{
    "in_features": {
        "url": "https://machine.domain.com/webadaptor/rest/services/Hosted/ServiceName/FeatureServer/0"
    },
    "buffer_distance_or_field": {
        "distance": 5,
        "units": "esriKilometers"
    },
    "esri_out_feature_service_name": {
        "serviceProperties": {
            "serviceUrl": "https://machine.domain.com/server/rest/services/Hosted/OutputFeatureServiceName/FeatureServer"
        },
        "itemProperties": {
            "overwrite": true,
            "newFeatureServiceOnOverwriteFail": true
        }
    }
}

You should leave this blank because the itemId cannot identify which task a geoprocessing service of that web tool item a task should schedule on, especially when there are multiple tasks in a geoprocessing service.

There is no limitation to the regular cron expression of a geoprocessing service task.

Task runs

The runs resources will list all the runs of a scheduled task, and for a geoprocessing service task run, it will list the Jobs URL and Result in the task run. From the Jobs URL, which corresponds to the Jobs resources of a geoprocessing service, you can get more information about the job, like the messages and final status. From the Result URL, which corresponds to the Results resource of a geoprocessing service, you can obtain all the values of all result parameters.

Task run of a geoprocessing service
task run

Other tasks and runs resources

Other tasks and run resources are also available, just like all other tasks like notebook tasks. These resources include disable a task, delete a run etc.

About the author

Simon is a product engineer on the geoprocessing services team since 2018. He works with different teams to improve the user experience of publishing and consuming geoprocessing services. Each year at the Esri User Conference and Developer Summit, he presents and supports users on topics related to geoprocessing services. Simon is also an opera lover and a world traveler.

Connect:
0 Comments
Inline Feedbacks
View all comments

Next Article

Use Arcade in Field Maps Designer

Read this article