Add to Definition (Feature Layer)

Description

The addToDefinition operation supports adding a definition property in a hosted feature service layer. The result of this operation is a response indicating success or failure with error code and description.

Parameters

Parameter

Details

f

Description: The response format. The default response format is html.

Values: html | json | pjson

addToDefinition

Description: The addToDefinition parameter supports adding a definition property in a hosted feature service layer.

async

Description: Supports options for asynchronous processing. The default format is false.

Values: true | false

Example usage

Example 1: Add fields to feature service layer

Example 2: Add indexes to feature service layer

Example 1: Add fields to feature service layer:

http://services.myserver.com/OrgID/ArcGIS/rest/admin/services/example1/FeatureServer/0/addToDefinition

Example input (POST body)

{
  "fields" : [
    {
      "name" : "GlobalID", 50/1
      "type" : "esriFieldTypeGlobalID", 
      "alias" : "GlobalID", 
      "sqlType" : "sqlTypeOther", 
      "nullable" : false, 
      "editable" : false, 
      "domain" : null, 
      "defaultValue" : "NEWID() WITH VALUES"
    },
    {
      "name" : "date1", 
      "type" : "esriFieldTypeDate", 
      "alias" : "date1", 
      "sqlType" : "sqlTypeOther", "length" : 8, 
      "nullable" : true, 
      "editable" : false, 
      "domain" : null, 
      "defaultValue" : "GetDate() WITH VALUES"
    },
    {   
      "name" : "str2", 
      "type" : "esriFieldTypeString", 
      "alias" : "str2", 
      "sqlType" : "sqlTypeNVarchar", "length" : 4, 
      "nullable" : true, 
      "editable" : true, 
      "domain" : null, 
      "defaultValue" : "'A' WITH VALUES"
    }

  ]
}

JSON Response syntax

{
  "success": <true|false>,
  "error": {
    "code": <code>,
    "message": "<description>",
    "details": [
      "<message>"
    ]
  }
}

JSON Response example (when addToDefinition succeeds)

{
  "success" : true
}

JSON Response example (when addToDefinition fails)

{
  "error" : 
  {
    "code" : 400, 
    "message" : "", 
    "details" : [
      "Unable to add feature service layer definition."
    ]
  }
}

Example 2: Add indexes to feature service layer:

http://services.myserver.com/ERmEceOGq5cHrItq/ArcGIS/rest/admin/services/example2/FeatureServer/0/addToDefinition

Example input (POST body)

{
  "indexes" : [
  {
    "name" : "index1",
    "fields" : "GlobalID, date1",
    "isUnique" : false,
    "isAscending" : false,
    "description" : "index1"   
  },
  {
    "name" : "index2",
    "fields" : "date1",
    "isUnique" : false,
    "isAscending" : false,
    "description" : "index2"   
  }
  
 ]
}

JSON Response syntax

{
  "success": <true|false>,
  "error": {
    "code": <code>,
    "message": "<description>",
    "details": [
      "<message>"
    ]
  }
}

JSON Response example (when addToDefinition succeeds)

{
  "success" : true
}

JSON Response example (when addToDefinition fails)

{
  "error" : 
  {
    "code" : 400, 
    "message" : "", 
    "details" : [
      "Unable to add feature service layer definition."
    ]
  }
}

10/6/2017