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.

New at 12.2

  • The Extract capability can now be set on joined views, which allows you to set the Create Replica operation's syncModel parameter to none to export to a supported format.
  • You can add field groups without specifying contingent values and use the new field groups later to add contingent values.
  • When adding new contingent values, the response returns an array of the added values along with their success status.

New at 11.5

  • The maximum field name length limit has been extended to 63 characters for hosted feature service layers on a relational store. When adding a field using this operation, you can confirm the supported maximum length by checking the maxFieldNameLength property on the layer's administrative resource.
  • Newly added fields are added to the subtypes by default when a layer has subtypes and a field is added using this operation.

New at 11.4

  • This operation now supports performing asynchronous requests for ArcGIS Enterprise hosted feature services.
  • This operation can create full text search indexes for hosted feature services.
  • This operation can add subtypes to a hosted feature service layer.

Request 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://organization.example.com/<OrgID>/ArcGIS/rest/admin/services/example/FeatureServer/0/addToDefinition

Example one: Add fields to a feature service layer

Example two: Add indexes to a feature service layer

Example three: Add subtypes to a feature layer

Example four: Create full text search index for a feature layer

Example five: Add a new field group to a feature service layer

Example six: Add contingent values to a feature service layer

Example one

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 two

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"
  }
 ]
}

Example three

Below is a sample JSON object for the addToDefinition parameter that demonstrates how to add two additional subtype codes to a feature service layer. Before performing this request, the layer already had subtypes defined for the building type field with four subtype codes (1, 2, 3, 4).

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
{
  "subtypes": [
    {
      "code": 5,
      "name": "commercial",
      "defaultValues": {
        "textfield": "commercial warehouse",
        "bldgtype": 5
      },
      "domains": {}
    },
    {
      "code": 6,
      "name": "school",
      "defaultValues": {
        "textfield": "university building",
        "bldgtype": 5
      },
      "domains": {}
    }
  ]
}

Example four

Below is a sample JSON object for the addToDefinition parameter that demonstrates creating a FullText index for a feature service layer. FullText indexes are only supported for layer fields with the type esriFieldTypeString.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
{
  "indexes": [
    {
      "name": "myFullText_indx",
      "indexType": "FullText",
      "fields": "city_name, state_city”,
      "description": "Layer settings"
    }
  ]
}

Example five

Below is a sample JSON object for the addToDefinition parameter that demonstrates how to add a field group 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
{
  "contingentValuesDefinition": {
    "fieldGroups": [
      {
        "name": "model_rating",
        "contingentValues": [
          {
            "fields": [
              {
                "name": "vmodel"
              },
              {
                "name": "vrating"
              }
            ]
          }
        ]
      }
    ]
  }
}

Example six

Below is a sample JSON object for the addToDefinition parameter that demonstrates how to add contingent values 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
31
32
33
34
35
36
37
38
39
40
{
  "contingentValuesDefinition": {
    "stringDicts": [
      {
        "entries": ["Good"],
        "domain": "drating"
      }
    ],
    "fieldGroups": [
      {
        "name": "make_rating",
        "restrictive": true,
        "subTypes": [
          {
            "code": 100,
            "name": "Airplane",
            "domains": {
              "vmake": "dmakes",
              "vrating": "drating"
            },
            "contingentValues": [
              {
                "types": [3,3],
                "values": [3,0]
              },
              {
                "types": [3,3],
                "values": [4,0]
              },
              {
                "types": [3,1],
                "values": [7]
              }
            ]
          }
        ]
      }
    ]
  }
}

JSON Response syntax

The example below reflects the syntax of a synchronous response:

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>"
    ]
  }
}

The example below reflects the syntax of a synchronous response with the added contingent value IDs being returned:

Use dark colors for code blocksCopy
1
2
3
4
{
  "addedContingentValueIds": [<id1>, <id2>, <id3>,...],
  "success": true
}

The example below reflects the syntax of an asynchronous response:

Use dark colors for code blocksCopy
1
{"statusURL": “<response status URL>”}

JSON Response examples

Synchronous responses

When addToDefinition succeeds as a synchronous response:

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

When addToDefinition fails as a synchronous response:

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."
    ]
  }
}

Asynchronous responses

When an addToDefinition request is submitted asynchronously, the response will include a statusURL, the value of which is a URL that can be accessed to check the status of the request:

Use dark colors for code blocksCopy
1
2
3
{
  "statusURL": "https://organization.example.com/<context>/rest/admin/services/myhostedservice/FeatureServer/0/addToDefinition/5f4f34c6-2bcf-41c7-8bd1-ea777570ad23"
}

The URL can be used to periodically check the progress of the request, which is returned as the status property. When the job completes, the response retrieved from the status URL will indicate whether the request completed successfully.

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
//success

{
  "submissionTime":1726444564500,
  "lastUpdatedTime":1726444568893,
  "status":"Completed"
}

//failure

{
  "submissionTime": 1726520769240,
  "lastUpdatedTime": 1726520769773,
  "status": "Failed",
  "error": {
    "code": 500,
    "description": "Editing definition error - RCPerfTestOneWayAllRowsParent.DBO.Volcano_Roop "
  }
}

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