Create Service

Description

The Create Service operation (POST only) allows users to create a hosted feature service. You can use the API to create an empty hosted feaure service from feature service metadata JSON.

Request Parameters

Parameter

Details

[Common Parameters]

For a complete listing, see Common parameters.

createParameters

A JSON object specifying the properties of the newly-created service. See the Create Parameters JSON object table below for further information.

outputType

The newly-created service type.

Value: featureService

Example: outputType=featureService

Create Parameters JSON object

The createParameters JSON object is descibed in the table below. All properties are optional unless marked as Required.

Property

Description

name

(Required) Name of the service to be created. This name must be unique. If the name already exists, the operation will fail.

serviceDescription

Description given to the service.

hasStaticData

Boolean value indicating whether the data changes.

maxRecordCount

A double value indicating any constraints enforced on query operations.

supportedQueryFormats

The formats in which query results are returned.

capabilities

Specify feature service editing capabilities for Create, Delete, Query, Update, and Sync.

description

A user-friendly description for the published dataset.

copyrightText

Copyright information associated with the dataset.

spatialReference

All layers added to a hosted feature service need to have the same spatial reference defined for the feature service. When creating a new empty service without specifying its spatial reference, the spatial reference of the hosted feature service is set to the first layer added to that feature service.

initialExtent

The initial extent set for the service.

allowGeometryUpdates

Boolean value indicating if updating the geometry of the service is permitted.

units

Units used by the feature service

xssPreventionInfo

A JSON object specifying the properties of cross-site scripting prevention. See the JSON object table below for further information.

CautionCaution:

The feature service fullExtent is a union of all its layers' extent. Adding a new layer to an existing feature service changes the feature service's fullExtent to include the new layer extent.

xssPreventionInfo JSON object

Property

Description

xssPreventionEnabled

Boolean value indicating whether cross-site scripting prevention is enabled.

xssPreventionRule

Either InputOnly | InputOutput

xssInputRule

Either rejectInvalid | sanitizeInvalid

Response Properties

Property

Details

encodedServiceURL

The encoded URL to the hosted service.

itemId

The unique ID for this item.

name

Name of the service item.

serviceItemId

The ID of the new service item.

serviceurl

The URL to the hosted service.

size

The size of the item.

success

Indicates if the operation was successful.

type

The type of service created.

description

The description of the new service item.

tags

The tags used to describe the service item.

snippet

Snippet or summary for the new service item.

Example Usage

URL for Create Service operation

http://www.arcgis.com/sharing/rest/content/users/jsmith/createService

Example of JSON used to create an empty service

The following shows an example of the createParameters JSON used to create a new empty hosted feature service

{
   "name" : "EmptyServiceName",
   "serviceDescription" : "",
   "hasStaticData" : false,
   "maxRecordCount" : 1000,
   "supportedQueryFormats" : "JSON",
   "capabilities" : "Create,Delete,Query,Update,Editing",
   "description" : "",
   "copyrightText" : "",
   "spatialReference" : {
      "wkid" : 102100
      },
   "initialExtent" : {
      "xmin" : -20037507.0671618,
      "ymin" : -30240971.9583862,
      "xmax" : 20037507.0671618,
      "ymax" : 18398924.324645,
      "spatialReference" : {
         "wkid" : 102100,
         "latestWkid" : 3857
         }
      },
   "allowGeometryUpdates" : true,
   "units" : "esriMeters",
   "xssPreventionInfo" : {
      "xssPreventionEnabled" : true,
      "xssPreventionRule" : "InputOnly",
      "xssInputRule" : "rejectInvalid"
      }
}

JSON Response Syntax

{
   "encodedServiceURL": <URL>,
   "itemId": "<item id>",
   "name": "<name of new service>",
   "serviceItemId": "<service id>",
   "serviceurl": "<url of service>",
   "size": "<size of new service>",
   "success": true | false,
   "type": "Feature Service",
   "description": "<description of the new service>",
   "tags": "<tags used for service>",
   "snippet": "<snippet given for service>"
}

JSON Response Example

{
"encodedServiceURL":"http://<server>.arcgis.com/J4hBlWAa0Sl7uI5e/arcgis/rest/
                     services/NewServiceName/FeatureServer",
"itemId":"eb55f55e8f60419dbbccabb60ece2af8",
"name":"NewServiceName",
"serviceItemId":"eb55f55e8f60419dbbccabb60ece2af8",
"serviceurl":"http://<server>.arcgis.com/J4hBlWAa0Sl7uI5e/
              arcgis/rest/services/NewServiceName/FeatureServer",
"size":-1,
"success":true,
"type":"Feature Service",
"description":"New Service",
"tags":"Empty service",
"snippet":"This is an empty service"
}

7/5/2017