- URL:
- https://<root>/<serviceName>/FeatureServer/<layerId>/queryRelatedRecords
- Methods:
GET
- Required Capability:
- Query
- Version Introduced:
- 10.0
Description
The query
operation is performed on a feature service layer resource. The result of this operation are feature sets grouped by source layer and table object IDs. Each feature set contains Feature objects including the values for the fields requested by the user. For related layers, if you request geometry information, the geometry of each feature is also returned in the feature set. For related tables, the feature set does not include geometries.
All parameters related to geometry are ignored when querying related tables.
New at 11.2
- This operation now supports pagination for non-hosted feature services that reference enterprise geodatabase data. Support for pagination is indicated when the layer-level
supports
property, underQuery Related Pagination advanced
, isQuery Capabilities true
. - Hosted and non-hosted feature services now support the
order
andBy return
parameters. Support for these parameters is indicated when the layer-levelCount Only supports
property, underAdvanced Query Related advanced
, isQuery Capabilities true
.
New at 11.1
Starting at ArcGIS Enterprise 11.1, qualifying hosted feature services now support pagination with the query
operation. Support for pagination is indicated when the layer-level supports
property, under advanced
, is true
.
New at 10.9
A new parameter, time
, has been added at 10.9. Setting time
as true
indicates that the client is capable of working with date field data values that are not in UTC. For more information on this parameter, see the Request parameters table below.
Request parameters
Parameter | Details |
---|---|
| The object IDs of the layer or table to be queried. Records related to these object IDs will be queried. Syntax
Example
|
| The ID of the relationship to be queried. The relationships in which this layer or table participates are included in the Feature Service Layer resource response. Records in tables or layers corresponding to the related table or layer of the relationship are queried. Example
|
| The list of fields from the related table or layer to be included in the returned feature set. This list is a comma delimited list of field names. If you specify the shape field in the list of return fields, it is ignored. To request geometry, set Example
|
| Related records returned by the Example
|
| If Values: |
| This option can be used to specify the Example
|
| This option can be used to specify the number of decimal places in the response geometries returned by the Example
|
| This option can be used for fetching query results by skipping the specified number of records and starting from the next record (that is, Example
|
| This option can be used for fetching query results up to the Example
|
| The spatial reference of the returned geometry. The spatial reference can be specified as either a well-known ID or a spatial reference json object. If |
| The geodatabase version to query. This parameter applies only if the Syntax
Example
|
| This option works with ArcGIS Server services only. The historic moment to query. This parameter applies only if the Syntax
Example
|
| If Values: |
| If Values: |
(Optional) | When set to Values: Example
|
| This parameter is used to request a list of the related records based on the field order. This list is a comma delimited list of field names. Syntax
Example
|
| If Values: Example
|
| Introduced at 10.8. This parameter applies a datum transformation while projecting geometries in the results when Syntax
Example
|
| Setting Its possible to define a service's time zone of date fields as unknown. Setting the time zone as unknown means that date values will be returned as-is from the database, rather than as date values in UTC. Non-hosted feature services can be set to use an unknown time zone using ArcGIS Server Manager. Setting the time zones to unknown also sets the Most clients released prior to ArcGIS Enterprise 10.9 will not be able to work with feature services that have an unknown time setting. The Value: |
| The response format. The default response format is Values: |
Example usage
- Example one
- Example two
- Example three
- Example four
Example one
The following is a sample request URL for the query
operation, which will query the related records as defined by relationship ID 2 that are related to the specified objectIds in layer 0:
https://machine.domain.com/webadaptor/rest/services/Petroleum/KSPetro/FeatureServer/0/queryRelatedRecords?objectIds=3,4,5&relationshipId=2&returnGeometry=true&outFields=*&f=html
Example two
The following is a sample request URL for the query
operation, which requests to skip the first two records and return the next four records where the objectId is greater than 3:
https://machine.domain.com/webadaptor/rest/services/RelationshipOID_test/FeatureServer/3/queryRelatedRecords?objectIds=&relationshipId=1&outFields=*&definitionExpression=ObjectID>3&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&outSR=&resultOffset=2&resultRecordCount=4&f=html
Example three
The following is a sample request URL for the query
operation, which will return the related records count for each specified objectId where TOWNSHIP
is the value for order
:
https://machine.domain.com/webadaptor/rest/services/KSPetro/FeatureServer/1/queryRelatedRecords?objectIds=7028,7029,71,6263,166,72,69,7126,6080,7522,335&relationshipId=1&outFields=OBJECTID&definitionExpression=&orderByFields=TOWNSHIP&returnCountOnly=true&returnGeometry=false&maxAllowableOffset=&geometryPrecision=&outSR=&resultOffset=&resultRecordCount=&f=html&token=
Example four
The following is a sample request URL for the query
operation, which will return the related records for each specified objectId where TOWNSHIP
is the value for both the out
and order
:
https://machine.domain.com/webadaptor/rest/services/Kansas_Petro_Data/FeatureServer/1/queryRelatedRecords?objectIds=7028,7029&relationshipId=1&outFields=TOWNSHIP&definitionExpression=1=1&orderByFields=TOWNSHIP&returnCountOnly=false&returnGeometry=false&maxAllowableOffset=&geometryPrecision=&outSR=&resultOffset=&resultRecordCount=&f=html&token=
JSON Response syntax
{
"geometryType": "<geometryType>", //if records include geometry
"spatialReference": <spatialReference>, //if records include geometry
"hasZ": <true|false>,
"hasM": <true|false>,
"fields": [
{
"name": "<fieldName1>",
"type": "<fieldType1>",
"alias": "<fieldAlias1>",
"length": "<length1>"
},
{
"name": "<fieldName2>",
"type": "<fieldType2>",
"alias": "<fieldAlias2>",
"length": "<length2>"
}
],
"relatedRecordGroups": [
{
"objectId": <objectId1>,
"relatedRecords": [ //features may include geometry for related layers only
<relatedFeature11>, <relatedFeature12>
]
},
{
"objectId": <objectId2>,
"relatedRecords": [
<relatedFeature21>, <relatedFeature22>
]
}
]
}
JSON Response example
- Example one
- Example two
- Example three
JSON Response example
Example one
The following is a sample response returned by the query
operation:
{
"geometryType": "esriGeometryPolygon",
"spatialReference": {
"wkid": 4267
},
"fields": [
{
"name": "OBJECTID",
"type": "esriFieldTypeOID",
"alias": "OBJECTID"
},
{
"name": "FIELD_KID",
"type": "esriFieldTypeString",
"alias": "FIELD_KID",
"length": 25
},
{
"name": "APPROXACRE",
"type": "esriFieldTypeDouble",
"alias": "APPROXACRE"
},
{
"name": "FIELD_NAME",
"type": "esriFieldTypeString",
"alias": "FIELD_NAME",
"length": 150
}
],
"relatedRecordGroups": [
{
"objectId": 3,
"relatedRecords": [
{
"attributes": {
"OBJECTID": 5540,
"FIELD_KID": "1000147595",
"APPROXACRE": 95929,
"FIELD_NAME": "LOST SPRINGS",
},
"geometry": {
"rings": [
[
[
-96.929599633999942,
38.52426809800005
],
[
-96.929602437999961,
38.522448437000037
],
[
-96.92959118999994,
38.529723252000053
],
[
-96.929594022999936,
38.527905578000059
],
[
-96.929596839999988,
38.526087119000067
],
[
-96.929599633999942,
38.52426809800005
]
]
]
}
}
]
}
]
}
Example two
The example below demonstrates a response that is returned when the request has the object
parameter set as 7028,7029
, the relationship
parameter is set as 1
, the out
parameter is set as TOWNSHIP
, the order
parameter is set as TOWNSHI
, the return
parameter is set as false
, and return
is set as false
:
{
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 33
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 34
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
},
{
"attributes": {
"TOWNSHIP": 24,
"RANGE": 35
}
}
}
Example three
The response example below demonstrates a response that is returned when the request has the object
parameter set as 7028,7029
, the relationship
parameter set as 1
, the return
parameter is set as true
, and the return
parameter is set as false
:
{
"relatedRecordGroups": [
{
"objectId": 7028,
"count": 10218
},
{
"objectId": 7029,
"count": 3304
}
]
}