Table of contents
iModel Query
Download API definition:
This operation is a Technical Preview and is available for testing purposes only. Do not use in production.
GET https://dev-api.bentley.com/imodel-query/itwins/{itwin}/imodels/{imodel}/changesets/{changeset}/queries/{queryId}[?limit][&skip][&includeMetadata]

Retrieves the results of an ECSQL query using the query ID. This operation is used to get results for queries that returned status 201 from the POST operation.

Query States

The response will include the current state of the query:

  • Pending: Query is queued for execution
  • Running: Query is currently being executed
  • Completed: Query finished successfully, results are available
  • Failed: Query execution failed, error details are provided

Query Parameters

The following optional query parameters control the response format and pagination:

  • includeMetadata - Whether to include column metadata in the response
  • limit - Maximum number of rows to return per page
  • skip - Number of rows to skip (for pagination)

Response Behavior

  • Pending queries: Returns query ID and current state only
  • Running queries: Returns query ID, current state, metadata (if requested), and any partial results available so far
  • Completed queries: Returns query ID, current state, metadata (if requested) and query results
  • Failed queries: Returns error information and failure details

Data Retention

Query results are available for 24 hours after completion. After this period, the query ID will no longer be valid.

Request parameters

Name
Required?
Description
itwin
Yes

iTwin ID

imodel
Yes

iModel ID

changeset
Yes

changeset ID

queryId
Yes

Query ID

limit
No

Maximum number of rows to return per page.

skip
No

Number of rows to skip.

includeMetadata
No

Whether to include column metadata in the response.

Request headers

Name
Required?
Description
Authorization
Yes

OAuth access token with itwin-platform scope

Accept
Yes

Setting to application/vnd.bentley.itwin-platform.v1+json is recommended.

Response 200 OK

A response

json
{
    "id": "620b43a3-a30e-48d8-92a8-ab1eb0fd591d",
    "state": "Completed",
    "rows": [
        [
            "0x1",
            "0xcf",
            {
                "Id": "0x1",
                "RelECClassId": "0x40"
            },
            "2022-12-15T12:40:13.047Z",
            {
                "Id": "0x1f",
                "RelECClassId": "0x47"
            },
            {
                "Id": "0x1",
                "RelECClassId": "0x49"
            },
            "BayTown_Sample"
        ]
    ],
    "links": {
        "self": "http://api.bentley.com/imodel-query/itwins/1f947d72-9983-4e46-89c2-e9ed9a3d4fec/imodels/4276bd1d-959b-4078-83c3-501571409a97/changesets/6cee950fcdfa3f01df925c04ed10fae1bfb233e7/queries/620b43a3-a30e-48d8-92a8-ab1eb0fd591d"
    },
    "meta": [{
            "className": "",
            "name": "ECInstanceId",
            "typeName": "long",
            "accessString": "ECInstanceId",
            "extendedType": "Id"
        },
        {
            "className": "",
            "name": "ECClassId",
            "typeName": "long",
            "accessString": "ECClassId",
            "extendedType": "ClassId"
        },
        {
            "className": "BisCore:Element",
            "name": "Model",
            "typeName": "navigation",
            "accessString": "Model"
        },
        {
            "className": "BisCore:Element",
            "name": "LastMod",
            "typeName": "dateTime",
            "accessString": "LastMod"
        },
        {
            "className": "BisCore:Element",
            "name": "CodeSpec",
            "typeName": "navigation",
            "accessString": "CodeSpec"
        },
        {
            "className": "BisCore:Element",
            "name": "CodeScope",
            "typeName": "navigation",
            "accessString": "CodeScope"
        },
        {
            "className": "BisCore:Element",
            "name": "CodeValue",
            "typeName": "string",
            "accessString": "CodeValue"
        },
        {
            "className": "BisCore:Element",
            "name": "UserLabel",
            "typeName": "string",
            "accessString": "UserLabel"
        },
        {
            "className": "BisCore:Element",
            "name": "Parent",
            "typeName": "navigation",
            "accessString": "Parent"
        },
        {
            "className": "BisCore:Element",
            "name": "FederationGuid",
            "typeName": "binary",
            "accessString": "FederationGuid",
            "extendedType": "BeGuid"
        },
        {
            "className": "BisCore:Element",
            "name": "JsonProperties",
            "typeName": "string",
            "accessString": "JsonProperties",
            "extendedType": "Json"
        }
    ]
}

Response 401 Unauthorized

This response indicates that request lacks valid authentication credentials. Access token might not been provided, issued by the wrong issuer, does not have required scopes or request headers were malformed.

json
{
    "error": {
        "code": "HeaderNotFound",
        "message": "Header Authorization was not found in the request. Access denied."
    }
}

Response 429 Too many requests

This response indicates that the client sent more requests than allowed by this API for the current tier of the client.

json
{
    "error": {
        "code": "RateLimitExceeded",
        "message": "The client sent more requests than allowed by this API for the current tier of the client."
    }
}

Response headers

Name
Description
retry-after

Number of seconds to wait until client is allowed to make more requests.

QueryResponse

Error

Contains error information.

Name
Type
Description
code
String

One of a server-defined set of error codes.

message
String

A human-readable representation of the error.

target
String, null

The target of the error.

Error Response

Gives details for an error that occurred while handling the request. Note that clients MUST NOT assume that every failed request will produce an object of this schema, or that all of the properties in the response will be non-null, as the error may have prevented this response from being constructed.

Name
Type
Description
error

Error information.

Was this page helpful?