- 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 supports
property is set as true
and the service has the Shared
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 user
value for the template, which specifies the template owner, will be set to the name of organization member that performs the operation. The template
field values are assigned by the system.
Request parameters
Parameter | Details |
---|---|
(Required) | An array of shared templates to be added. The array must contain the following fields:
A full list of fields that can be included can be found in the Shared Templates resource. Syntax
Example
|
(Optional) | If set to Values: |
| The response format. The default format is Values: |
Example usage
The following is a sample POST request for the add
operation that demonstrates adding two feature templates, with use
set as false
:
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:
[
{
"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
[
{
<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:
[
{
"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.
{
"error": {
"code": 400,
"message": "Unable to complete operation.",
"details": [
"Parameter 'layerId' is required."
]
}
}