Query - Query Twins
İlişkilerde gezinmeye ve özellik değerlerine göre filtrelemeye olanak tanıyan bir sorgu yürütür. Durum kodları:
- 200 Tamam
- 400 Hatalı İstek
- BadRequest - Devamlılık belirteci geçersiz.
- SqlQueryError - Sorgu bazı hatalar içeriyor.
- TimeoutError - Sorgu yürütmesi 60 saniye sonra zaman aşımına uğradı. Sonuç boyutunu küçültmek için sorguyu basitleştirmeyi veya koşullar eklemeyi deneyin.
- 429 Çok Fazla İstek Var
- QuotaReachedError - Sorgu hızı üst sınırına ulaşıldı.
POST https://digitaltwins-hostname/query?api-version=2023-10-31
URI Parametreleri
Name | İçinde | Gerekli | Tür | Description |
---|---|---|---|---|
api-version
|
query | True |
string |
İstenen API sürümü. |
İstek Başlığı
Name | Gerekli | Tür | Description |
---|---|---|---|
max-items-per-page |
integer |
İstek başına alınacak en fazla öğe sayısı. Sunucu istenen sayıdan daha az döndürmeyi seçebilir. |
|
traceparent |
string |
Dağıtılmış izleme sisteminde isteği tanımlar. |
|
tracestate |
string |
Satıcıya özgü izleme tanımlama bilgilerini sağlar ve izleme aracına eşlik eder. |
İstek Gövdesi
Name | Tür | Description |
---|---|---|
continuationToken |
string |
Önceki bir sorgudan sonraki sonuç kümesini almak için kullanılan belirteç. |
query |
string |
Yürütülecek sorgu. Bir devamlılık belirteci sağlanırsa bu değer yoksayılır. |
Yanıtlar
Name | Tür | Description |
---|---|---|
200 OK |
Başarılı Headers query-charge: number |
|
Other Status Codes |
Varsayılan yanıt. Headers x-ms-error-code: string |
Güvenlik
oauth2
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize?resource=0b07f429-9f4b-4714-9392-cc5e8e80c8b0
Örnekler
Query for digital twins |
Query for digital twins through a relationship |
Retrieve paged query results |
Query for digital twins
Sample Request
POST https://digitaltwins-hostname/query?api-version=2023-10-31
{
"query": "SELECT * FROM DIGITALTWINS WHERE temp = 79"
}
Sample Response
{
"value": [
{
"$dtId": "Twin-01",
"$metadata": {
"$lastUpdateTime": "2022-02-28T00:30:00.1234567Z",
"$model": "dtmi:com:example:Sample;1",
"name": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
},
"temp": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
},
"comfortIndex": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
}
},
"name": "Sample01",
"temp": 79,
"comfortIndex": 50
},
{
"$dtId": "Twin-02",
"$metadata": {
"$lastUpdateTime": "2022-02-28T00:29:00.1234567Z",
"$model": "dtmi:com:example:Sample;1",
"name": {
"lastUpdateTime": "2022-02-28T00:29:00.1234567Z"
},
"temp": {
"lastUpdateTime": "2022-02-28T00:29:00.1234567Z",
"sourceTime": "2022-05-31T12:00:00.000125009Z"
},
"comfortIndex": {
"lastUpdateTime": "2022-02-28T00:29:00.1234567Z"
}
},
"name": "Sample02",
"temp": 79,
"comfortIndex": 50
},
{
"$dtId": "Twin-03",
"$metadata": {
"$lastUpdateTime": "2022-02-28T00:31:00.1234567Z",
"$model": "dtmi:com:example:Sample;1",
"name": {
"lastUpdateTime": "2022-02-28T00:31:00.1234567Z"
},
"temp": {
"lastUpdateTime": "2022-02-28T00:31:00.1234567Z"
},
"comfortIndex": {
"lastUpdateTime": "2022-02-28T00:31:00.1234567Z"
}
},
"name": "Sample03",
"temp": 79,
"comfortIndex": 50
}
],
"continuationToken": "<token>"
}
Query for digital twins through a relationship
Sample Request
POST https://digitaltwins-hostname/query?api-version=2023-10-31
{
"query": "SELECT Widget, Gadget FROM DIGITALTWINS Widget JOIN Gadget RELATED Widget.Contains WHERE Widget.$dtId = 'Twin-01'"
}
Sample Response
{
"value": [
{
"Widget": {
"$dtId": "Twin-01",
"$metadata": {
"$lastUpdateTime": "2022-02-28T00:30:00.1234567Z",
"$model": "dtmi:com:example:Sample;1",
"name": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
},
"temp": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
},
"comfortIndex": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
}
},
"name": "Sample01",
"temp": 79,
"comfortIndex": 50
},
"Gadget": {
"$dtId": "Twin-02",
"$metadata": {
"$lastUpdateTime": "2022-02-28T00:30:00.1234567Z",
"$model": "dtmi:com:example:Sample;1",
"name": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
},
"temp": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
},
"comfortIndex": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
}
},
"name": "Sample02",
"temp": 79,
"comfortIndex": 50
}
},
{
"Widget": {
"$dtId": "Twin-01",
"$metadata": {
"$lastUpdateTime": "2022-02-28T00:30:00.1234567Z",
"$model": "dtmi:com:example:Sample;1",
"name": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
},
"temp": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
},
"comfortIndex": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
}
},
"name": "Sample01",
"temp": 79,
"comfortIndex": 50
},
"Gadget": {
"$dtId": "Twin-10",
"$metadata": {
"$lastUpdateTime": "2022-02-28T00:30:00.1234567Z",
"$model": "dtmi:com:example:Sample;1",
"name": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
},
"temp": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
},
"comfortIndex": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
}
},
"name": "Sample10",
"temp": 79,
"comfortIndex": 50
}
}
]
}
Retrieve paged query results
Sample Request
POST https://digitaltwins-hostname/query?api-version=2023-10-31
{
"continuationToken": "<continuationToken from previous query>"
}
Sample Response
{
"value": [
{
"$dtId": "Twin-04",
"$metadata": {
"$lastUpdateTime": "2022-02-28T00:30:00.1234567Z",
"$model": "dtmi:com:example:Sample;1",
"name": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
},
"temp": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
},
"comfortIndex": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
}
},
"name": "Sample04",
"temp": 79,
"comfortIndex": 50
},
{
"$dtId": "Twin-05",
"$metadata": {
"$lastUpdateTime": "2022-02-28T00:30:00.1234567Z",
"$model": "dtmi:com:example:Sample;1",
"name": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
},
"temp": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
},
"comfortIndex": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
}
},
"name": "Sample05",
"temp": 79,
"comfortIndex": 50
},
{
"$dtId": "Twin-06",
"$metadata": {
"$lastUpdateTime": "2022-02-28T00:30:00.1234567Z",
"$model": "dtmi:com:example:Sample;1",
"name": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
},
"temp": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
},
"comfortIndex": {
"lastUpdateTime": "2022-02-28T00:30:00.1234567Z"
}
},
"name": "Sample06",
"temp": 79,
"comfortIndex": 50
}
]
}
Tanımlar
Name | Description |
---|---|
Error |
Hata tanımı. |
Error |
Hata yanıtı. |
Inner |
İçeren hata tarafından sağlanandan daha belirgin bir hata açıklaması. |
Query |
Sorgu işleminin sonuçları ve isteğe bağlı bir devamlılık belirteci. |
Query |
Önceki sorgu sonucundan bir sorgu deyimi veya devamlılık belirteci içeren sorgu belirtimi. |
Error
Hata tanımı.
Name | Tür | Description |
---|---|---|
code |
string |
HTTP hata kodu için alt durum görevi gören hizmete özgü hata kodu. |
details |
Error[] |
İç hata ayrıntıları. |
innererror |
Hatayla ilgili geçerli nesneden daha belirli bilgiler içeren bir nesne. |
|
message |
string |
Hatanın insanlar tarafından okunabilir bir gösterimi. |
ErrorResponse
Hata yanıtı.
Name | Tür | Description |
---|---|---|
error |
Hata ayrıntıları. |
InnerError
İçeren hata tarafından sağlanandan daha belirgin bir hata açıklaması.
Name | Tür | Description |
---|---|---|
code |
string |
İçeren hata tarafından sağlanandan daha özel bir hata kodu. |
innererror |
Hatayla ilgili geçerli nesneden daha belirli bilgiler içeren bir nesne. |
QueryResult
Sorgu işleminin sonuçları ve isteğe bağlı bir devamlılık belirteci.
Name | Tür | Description |
---|---|---|
continuationToken |
string |
Sonraki sonuç kümesini almak üzere yeni bir QuerySpecification oluşturmak için kullanılabilecek bir belirteç. |
value |
object[] |
Sorgu sonuçları. |
QuerySpecification
Önceki sorgu sonucundan bir sorgu deyimi veya devamlılık belirteci içeren sorgu belirtimi.
Name | Tür | Description |
---|---|---|
continuationToken |
string |
Önceki bir sorgudan sonraki sonuç kümesini almak için kullanılan belirteç. |
query |
string |
Yürütülecek sorgu. Bir devamlılık belirteci sağlanırsa bu değer yoksayılır. |
Geri Bildirim
https://aka.ms/ContentUserFeedback.
Çok yakında: 2024 boyunca, içerik için geri bildirim mekanizması olarak GitHub Sorunları’nı kullanımdan kaldıracak ve yeni bir geri bildirim sistemiyle değiştireceğiz. Daha fazla bilgi için bkz.Gönderin ve geri bildirimi görüntüleyin