Add To Definition (Feature Layer)

URL:
https://<adminRoot>/services/<serviceName>/FeatureServer/<layerId>/addToDefinition
Methods:
GET

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 a response indicating failure with an error code and description.

Parameters

ParameterDetails

addToDefinition

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

async

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

Values: true | false

f

The response format. The default response format is html .

Values: html | json | pjson

Example usage

Use dark colors for code blocksCopy
1
https://services.myserver.com/OrgID/ArcGIS/rest/admin/services/example/FeatureServer/0/addToDefinition

Example 1: Add fields to a feature service layer

Example 2: Add indexes to a feature service layer

Example 1

Below is a sample JSON object for the addToDefinition parameter that demonstrates how to add fields to a feature service layer:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{
  "fields": [
    {
      "name": "GlobalID",
      "type": "esriFieldTypeGlobalID",
      "alias": "GlobalID",
      "nullable": false,
      "editable": false
    },
    {
      "name": "date1",
      "type": "esriFieldTypeDate",
      "alias": "date1",
      "nullable": true,
      "editable": false,
      "domain": null,
      "defaultValue": "GetDate() WITH VALUES"
    },
    {
      "name": "str2",
      "type": "esriFieldTypeString",
      "alias": "str2",
      "nullable": true,
      "editable": true,
      "domain": null,
      "defaultValue": "'A' WITH VALUES"
    }

  ]
}

Example 2

Below is a sample JSON object for the addToDefinition parameter that demonstrates how to add indexes to a feature service layer:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
  "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

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
{
  "success": <true|false>,
  "error": {
    "code": <code>,
    "message": "<description>",
    "details": [
      "<message>"
    ]
  }
}

JSON Response examples

When addToDefinition succeeds:

Use dark colors for code blocksCopy
1
2
3
{
  "success": true
}

When addToDefinition fails:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
{
  "error": {
    "code": 400,
    "message": "",
    "details": [
      "Unable to add feature service layer definition."
    ]
  }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.