Add (Feature Service/Shared Templates)

URL:
https://<root>/services/<serviceName>/sharedTemplates/add
Methods:
POST
Required Capability:
SharedTemplateEditing capability enabled on the service
Version Introduced:
11.4

Description

The add operation adds shared templates to the back-end data source. These templates can be used by any service that references the same back-end datasets. This operation can support adding multiple templates within the same request. Support for this operation is indicated when the service's supportsSharedTemplates property is set as true and the service has the SharedTemplateEditing capability enabled.

When adding preset templates, if feature geometries are specified without an explicit spatial reference, the geometries are assumed to be in the service's spatial reference. The userIdentity value for the template, which specifies the template owner, will be set to the name of organization member that performs the operation. The templateId field values are assigned by the system.

Request parameters

ParameterDetails

sharedTemplates

(Required)

An array of shared templates to be added. The array must contain the following fields:

  • name

  • type

  • layerId

  • visible

  • status

  • definition

  • subtype (required if the data contains subtypes)

  • globalId (required if the useGlobalIds parameter is set as true)

A full list of fields that can be included can be found in the Shared Templates resource.

Syntax

Use dark colors for code blocksCopy
1
sharedTemplates=[<sharedTemplate1>, < sharedTemplate2>]

Example

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
[
  {
    "globalId": "{D060DABE-265A-4428-BEFB-DFA5FFC42C20}",
    "name": "Hydrant",
    "defaultTool": "{2A8B3331-5238-4025-972E-452A69535B06}",
    "type": "feature",
    "layerId": 13,
    "subtype": null,
    "description": "",
    "tags": "Point",
    "visible": true,
    "status": "protected",
    "definition": {
      "defaultValues": {
        "ATEXT": "Hydrant"
      }
    }
  },
  ...
]

useGlobalIds

(Optional)

If set to true, the unique globalId value must be included for each new template. Including globalId values is important when adding sets of related templates, such as adding a group template. The default value is false.

Values: true | false

f

The response format. The default format is html.

Values: html | json | pjson

Example usage

The following is a sample POST request for the add operation that demonstrates adding two feature templates, with useGlobalIds set as false:

Use dark colors for code blocksCopy
1
2
3
4
5
6
POST /webadaptor/rest/services/MyService/FeatureServer/sharedTemplates/add HTTP/1/1
Host: machine.domain.com
Content-Type: application/x-www-form-urlencoded
Content-Length: []

sharedTemplates=[{"name": "My Point","defaultTool": "{2A8B3331-5238-4025-972E-452A69535B06}","type": "feature","layerId": 12,"subtype": null,"description": "","tag": "Point","visible": true,"status": "protected","definition": {"defaultValues": {"ATEXT": "Hydrant"}}},{"name": "My Feature","defaultTool": "{2A8B3331-5238-4025-972E-452A69535B06}","type": "feature","layerId": 13,"subtype": null,"description": "","tag": "Point","visible": true,"status": "protected","definition": {"defaultValues": {"ATEXT": "Building A"}}}]&useGlobalIds=false&f=pjson

The sample code below show the JSON array in the above request, formatted for readability:

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
[
  {
    "name": "My Point",
    "defaultTool": "{2A8B3331-5238-4025-972E-452A69535B06}",
    "type": "feature",
    "layerId": 12,
    "subtype": null,
    "description": "",
    "tag": "Point",
    "visible": true,
    "status": "protected",
    "definition": {
      "defaultValues": {
        "ATEXT": "Hydrant"
      }
    }
  },
  {
    "name": "My Feature",
    "defaultTool": "{2A8B3331-5238-4025-972E-452A69535B06}",
    "type": "feature",
    "layerId": 13,
    "subtype": null,
    "description": "",
    "tag": "Point",
    "visible": true,
    "status": "protected",
    "definition": {
      "defaultValues": {
        "ATEXT": "Building A"
      }
    }
  }
]

JSON Response syntax

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
[
  {
    <result1>
  },
  {
    <result2>
  }
]

JSON Response example

The sample response below demonstrates the response returned when the operation completes successfully. The example below shows that two shared templates were successfully added:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
[
  {
    "templateId": 51,
    "globalId": "{83EDCDB5-9CEE-4384-B713-18BD1969D819}",
    "hash": "{1E597512-A127-4516-80A4-8DB449D0E257}"
  },
  {
    "templateId": 52,
    "globalId": "{DF6534B7-DE7C-425B-8B08-4DB789A39A01}",
    "hash": "{B957F388-EF63-467C-A13E-F5C3E530C599}"
  }
]

The sample response below demonstrates the response returned when the operation fails. When the operation fails, all changes are rolled back and the failure message returned as part of the response is for the first template that has failed.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
{
  "error": {
    "code": 400,
    "message": "Unable to complete operation.",
    "details": [
      "Parameter 'layerId' is required."
    ]
  }
}

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