웹 API 쿼리 데이터 샘플
게시 날짜: 2017년 1월
적용 대상: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online
이 그룹의 샘플은 Microsoft Dynamics 365 웹 API를 사용하여 데이터를 쿼리하는 방법에 대해 설명합니다. 이 샘플은 다음 언어에 대해 별도 프로젝트로 구현됩니다.
이 항목에서는 그룹의 각 샘플이 구현하는 작업의 공통 집합에 대해 설명합니다. 이 항목에서는 특정 언어에 대한 세부 내용 없이 이 그룹의 각 샘플이 수행할 HTTP 요청 및 응답과 텍스트에 대해 다룹니다. 특정 언어에 대한 설명 및 이 작업을 수행하는 방법에 대한 개별 샘플의 자세한 내용을 참조하십시오.
시연
이 샘플은 웹 관련 개념 항목에서 보다 자세히 다룰 API 쿼리 데이터 작업을 포함하는 다음의 주요 섹션으로 구분됩니다.
항목 섹션 |
관련된 항목 |
---|---|
특정 속성 선택 |
|
쿼리 함수 사용 |
|
연산자 사용 |
|
우선 순위 설정 |
|
결과 순서 설정 |
|
매개 변수 별칭 |
|
결과 제한 |
|
결과 확장 |
|
FetchXML 쿼리 |
|
미리 정의된 쿼리 |
다음 섹션에서는 수행되는 Dynamics 365 웹 API 작업과 해당 HTTP 메시지 및 관련 콘솔 출력에 대한 간략한 설명을 담고 있습니다.
샘플 데이터
이 샘플의 쿼리가 제대로 작동하게 하기 위해 이 샘플에서는 표준 샘플 레코드 집합을 만듭니다. 사용자가 파일을 삭제하지 않도록 선택하지 않으면 이러한 예제 레코드는 삭제됩니다. 샘플에서 쿼리할 데이터입니다. 사용자 환경의 기존 데이터에 따라 다른 결과가 발생할 수 있습니다.
데이터는 단일 POST 요청에서 깊은 삽입을 사용하여 추가하며 다음의 구조와 일치합니다.
{
"name": "Contoso, Ltd. (sample)",
"primarycontactid": {
"firstname": "Yvonne", "lastname": "McKay (sample)", "jobtitle": "Coffee Master",
"annualincome": 45000, "Contact_Tasks": [
{ "subject": "Task 1", "description": "Task 1 description" },
{ "subject": "Task 2", "description": "Task 2 description" },
{ "subject": "Task 3", "description": "Task 3 description" }
]
},
"Account_Tasks": [
{ "subject": "Task 1", "description": "Task 1 description" },
{ "subject": "Task 2", "description": "Task 2 description" },
{ "subject": "Task 3", "description": "Task 3 description" }
],
"contact_customer_accounts": [
{
"firstname": "Susanna", "lastname": "Stubberod (sample)", "jobtitle": "Senior Purchaser",
"annualincome": 52000, "Contact_Tasks": [
{ "subject": "Task 1", "description": "Task 1 description" },
{ "subject": "Task 2", "description": "Task 2 description" },
{ "subject": "Task 3", "description": "Task 3 description" }
]
},
{
"firstname": "Nancy", "lastname": "Anderson (sample)", "jobtitle": "Activities Manager",
"annualincome": 55500, "Contact_Tasks": [
{ "subject": "Task 1", "description": "Task 1 description" },
{ "subject": "Task 2", "description": "Task 2 description" },
{ "subject": "Task 3", "description": "Task 3 description" }
]
},
{
"firstname": "Maria", "lastname": "Cambell (sample)", "jobtitle": "Accounts Manager",
"annualincome": 31000, "Contact_Tasks": [
{ "subject": "Task 1", "description": "Task 1 description" },
{ "subject": "Task 2", "description": "Task 2 description" },
{ "subject": "Task 3", "description": "Task 3 description" }
]
},
{
"firstname": "Nancy", "lastname": "Anderson (sample)", "jobtitle": "Logistics Specialist",
"annualincome": 63500, "Contact_Tasks": [
{ "subject": "Task 1", "description": "Task 1 description" },
{ "subject": "Task 2", "description": "Task 2 description" },
{ "subject": "Task 3", "description": "Task 3 description" }
]
},
{
"firstname": "Scott", "lastname": "Konersmann (sample)", "jobtitle": "Accounts Manager",
"annualincome": 38000, "Contact_Tasks": [
{ "subject": "Task 1", "description": "Task 1 description" },
{ "subject": "Task 2", "description": "Task 2 description" },
{ "subject": "Task 3", "description": "Task 3 description" }
]
},
{
"firstname": "Robert", "lastname": "Lyon (sample)", "jobtitle": "Senior Technician",
"annualincome": 78000, "Contact_Tasks": [
{ "subject": "Task 1", "description": "Task 1 description" },
{ "subject": "Task 2", "description": "Task 2 description" },
{ "subject": "Task 3", "description": "Task 3 description" }
]
},
{
"firstname": "Paul", "lastname": "Cannon (sample)", "jobtitle": "Ski Instructor",
"annualincome": 68500, "Contact_Tasks": [
{ "subject": "Task 1", "description": "Task 1 description" },
{ "subject": "Task 2", "description": "Task 2 description" },
{ "subject": "Task 3", "description": "Task 3 description" }
]
},
{
"firstname": "Rene", "lastname": "Valdes (sample)", "jobtitle": "Data Analyst III",
"annualincome": 86000, "Contact_Tasks": [
{ "subject": "Task 1", "description": "Task 1 description" },
{ "subject": "Task 2", "description": "Task 2 description" },
{ "subject": "Task 3", "description": "Task 3 description" }
]
},
{
"firstname": "Jim", "lastname": "Glynn (sample)", "jobtitle": "Senior International Sales Manager",
"annualincome": 81400, "Contact_Tasks": [
{ "subject": "Task 1", "description": "Task 1 description" },
{ "subject": "Task 2", "description": "Task 2 description" },
{ "subject": "Task 3", "description": "Task 3 description" }
]
}
]
}
특정 속성 선택
항상 $select 쿼리 옵션을 사용하여 쿼리를 구성하십시오. 그렇지 않으면 각 엔터티의 모든 속성을 반환하여 성능이 저하됩니다. 이 예제는 contact EntityType의 세 가지 속성을 선택하여 기본 쿼리를 작성하는 방법을 보여줍니다. 속성은 fullname, jobtitle, annualincome이 있습니다. 이 섹션에서는 연락처의 annualincome 속성의 결과에서 볼 수 있는 서식 있는 값과 서식 있는 값의 차이점 또한 설명합니다.추가 정보:특정 속성을 요청합니다., 형식이 지정된 값 포함.
이 예제에서는 특정 연락처를 요청합니다. 이 경우 특정 연락처는 거래처의 기본 연락처인 Yvonne McKay (sample)입니다.
HTTP 요청
GET http://cc_WebAPI_ServiceURI/contacts(b848fdee-c143-e611-80d5-00155da84802)?$select=fullname,jobtitle,annualincome HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Preference-Applied: odata.maxpagesize=10
Content-Length: 517
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#contacts(fullname,jobtitle,annualincome)/$entity",
"@odata.etag":"W/\"619718\"",
"fullname":"Yvonne McKay (sample)",
"jobtitle":"Coffee Master",
"annualincome@OData.Community.Display.V1.FormattedValue":"$45,000.00",
"annualincome":45000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"15c364b2-bf43-e611-80d5-00155da84802"
}
콘솔 출력
Contact basic info:
Fullname: 'Yvonne McKay (sample)'
Jobtitle: 'Coffee Master'
Annualincome: '45000' (unformatted)
Annualincome: $45,000.00 (formatted)
쿼리 함수 사용
필터 옵션을 사용하여 원하는 결과에 대한 조건을 설정할 수 있습니다. 쿼리 함수, 비교 연산자 및 논리 연산자를 조합하여 단순하거나 복잡한 필터를 만들 수 있습니다.추가 정보:필터 결과.
쿼리 함수는 쿼리에서 필터 조건으로 사용할 수 있는 함수입니다. 표준 쿼리 함수와 Dynamics 365 특정 쿼리 함수가 있습니다. 이 함수들은 매개 변수를 허용하고 Boolean 값을 반환합니다. 이 샘플에는 각 유형의 쿼리를 만드는 방법을 보여줍니다.
표준 쿼리 함수
Dynamics 365는 OData 기본 제공 쿼리 기능 중 일부인 contains, endswith, 및 startswith만 지원합니다. 예를 들어 contains 표준 쿼리 함수를 사용하면 문자열과 일치하는 속성을 필터링할 수 있습니다. 이 작업에서는 (sample) 문자열이 포함된 fullname의 모든 연락처를 쿼리합니다.추가 정보:표준 쿼리 함수.
HTTP 요청
GET http://cc_WebAPI_ServiceURI/contacts?$select=fullname,jobtitle,annualincome&$filter=contains(fullname,'(sample)') HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Preference-Applied: odata.maxpagesize=10
Content-Length: 4284
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#contacts(fullname,jobtitle,annualincome)",
"value":[
{
"@odata.etag":"W/\"619718\"",
"fullname":"Yvonne McKay (sample)",
"jobtitle":"Coffee Master",
"annualincome@OData.Community.Display.V1.FormattedValue":"$45,000.00",
"annualincome":45000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"15c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619839\"",
"fullname":"Susanna Stubberod (sample)",
"jobtitle":"Senior Purchaser",
"annualincome@OData.Community.Display.V1.FormattedValue":"$52,000.00",
"annualincome":52000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"1cc364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619841\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Activities Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$55,500.00",
"annualincome":55500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"20c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619843\"",
"fullname":"Maria Cambell (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$31,000.00",
"annualincome":31000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"24c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619845\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Logistics Specialist",
"annualincome@OData.Community.Display.V1.FormattedValue":"$63,500.00",
"annualincome":63500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"28c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619847\"",
"fullname":"Scott Konersmann (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$38,000.00",
"annualincome":38000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"2cc364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619849\"",
"fullname":"Robert Lyon (sample)",
"jobtitle":"Senior Technician",
"annualincome@OData.Community.Display.V1.FormattedValue":"$78,000.00",
"annualincome":78000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"30c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619851\"",
"fullname":"Paul Cannon (sample)",
"jobtitle":"Ski Instructor",
"annualincome@OData.Community.Display.V1.FormattedValue":"$68,500.00",
"annualincome":68500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"34c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619853\"",
"fullname":"Rene Valdes (sample)",
"jobtitle":"Data Analyst III",
"annualincome@OData.Community.Display.V1.FormattedValue":"$86,000.00",
"annualincome":86000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"38c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619855\"",
"fullname":"Jim Glynn (sample)",
"jobtitle":"Senior International Sales Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$81,400.00",
"annualincome":81400.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"3cc364b2-bf43-e611-80d5-00155da84802"
}
]
}
콘솔 출력
Contacts filtered by fullname containing '(sample)':
1) Yvonne McKay (sample), Coffee Master, $45,000.00
2) Susanna Stubberod (sample), Senior Purchaser, $52,000.00
3) Nancy Anderson (sample), Activities Manager, $55,500.00
4) Maria Cambell (sample), Accounts Manager, $31,000.00
5) Nancy Anderson (sample), Logistics Specialist, $63,500.00
6) Scott Konersmann (sample), Accounts Manager, $38,000.00
7) Robert Lyon (sample), Senior Technician, $78,000.00
8) Paul Cannon (sample), Ski Instructor, $68,500.00
9) Rene Valdes (sample), Data Analyst III, $86,000.00
10) Jim Glynn (sample), Senior International Sales Manager, $81,400.00
Dynamics 365 쿼리 함수
Dynamics 365 쿼리 함수는 Dynamics 365에 관련된 쿼리를 작성하는 다양한 옵션을 제공합니다. 이러한 함수의 전체 목록은 Web API Query Function Reference를 참조하십시오.추가 정보:함수를 사용하여 쿼리를 작성합니다.
표준 쿼리 함수와 비슷한 방식으로 이러한 쿼리 함수를 사용합니다. 주요 차이점은 Dynamics 365 쿼리 함수를 사용할 때 매개 변수 이름을 포함하는 함수의 전체 이름을 제공해야 합니다. 예를 들어, 마지막 한 시간 동안에 만든 연락처 목록을 얻으려면 LastXHours Function을 사용하여 쿼리를 구성할 수 있습니다.
HTTP 요청
GET http://cc_WebAPI_ServiceURI/contacts?$select=fullname,jobtitle,annualincome&$filter=Microsoft.Dynamics.CRM.LastXHours(PropertyName='createdon',PropertyValue='1') HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Preference-Applied: odata.maxpagesize=10
Content-Length: 4284
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#contacts(fullname,jobtitle,annualincome)",
"value":[
{
"@odata.etag":"W/\"619718\"",
"fullname":"Yvonne McKay (sample)",
"jobtitle":"Coffee Master",
"annualincome@OData.Community.Display.V1.FormattedValue":"$45,000.00",
"annualincome":45000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"15c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619839\"",
"fullname":"Susanna Stubberod (sample)",
"jobtitle":"Senior Purchaser",
"annualincome@OData.Community.Display.V1.FormattedValue":"$52,000.00",
"annualincome":52000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"1cc364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619841\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Activities Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$55,500.00",
"annualincome":55500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"20c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619843\"",
"fullname":"Maria Cambell (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$31,000.00",
"annualincome":31000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"24c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619845\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Logistics Specialist",
"annualincome@OData.Community.Display.V1.FormattedValue":"$63,500.00",
"annualincome":63500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"28c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619847\"",
"fullname":"Scott Konersmann (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$38,000.00",
"annualincome":38000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"2cc364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619849\"",
"fullname":"Robert Lyon (sample)",
"jobtitle":"Senior Technician",
"annualincome@OData.Community.Display.V1.FormattedValue":"$78,000.00",
"annualincome":78000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"30c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619851\"",
"fullname":"Paul Cannon (sample)",
"jobtitle":"Ski Instructor",
"annualincome@OData.Community.Display.V1.FormattedValue":"$68,500.00",
"annualincome":68500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"34c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619853\"",
"fullname":"Rene Valdes (sample)",
"jobtitle":"Data Analyst III",
"annualincome@OData.Community.Display.V1.FormattedValue":"$86,000.00",
"annualincome":86000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"38c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619855\"",
"fullname":"Jim Glynn (sample)",
"jobtitle":"Senior International Sales Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$81,400.00",
"annualincome":81400.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"3cc364b2-bf43-e611-80d5-00155da84802"
}
]
}
콘솔 출력
Contacts that were created within the last 1hr:
1) Yvonne McKay (sample), Coffee Master, $45,000.00
2) Susanna Stubberod (sample), Senior Purchaser, $52,000.00
3) Nancy Anderson (sample), Activities Manager, $55,500.00
4) Maria Cambell (sample), Accounts Manager, $31,000.00
5) Nancy Anderson (sample), Logistics Specialist, $63,500.00
6) Scott Konersmann (sample), Accounts Manager, $38,000.00
7) Robert Lyon (sample), Senior Technician, $78,000.00
8) Paul Cannon (sample), Ski Instructor, $68,500.00
9) Rene Valdes (sample), Data Analyst III, $86,000.00
10) Jim Glynn (sample), Senior International Sales Manager, $81,400.00
연산자 사용
표준 필터 연산자(eq,ne,gt,ge,lt,le,and,or,not)를 사용하여 결과를 구체화합니다. 이 예제에서는 (sample)을(를) 포함하는 fullname의 55000보다 큰 연간 수입의 전체 연락처 목록을 요청합니다.
HTTP 요청
GET http://cc_WebAPI_ServiceURI/contacts?$select=fullname,jobtitle,annualincome&$filter=contains(fullname,'(sample)')%20and%20annualincome%20gt%2055000 HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Preference-Applied: odata.maxpagesize=10
Content-Length: 2629
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#contacts(fullname,jobtitle,annualincome)",
"value":[
{
"@odata.etag":"W/\"619841\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Activities Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$55,500.00",
"annualincome":55500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"20c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619845\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Logistics Specialist",
"annualincome@OData.Community.Display.V1.FormattedValue":"$63,500.00",
"annualincome":63500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"28c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619849\"",
"fullname":"Robert Lyon (sample)",
"jobtitle":"Senior Technician",
"annualincome@OData.Community.Display.V1.FormattedValue":"$78,000.00",
"annualincome":78000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"30c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619851\"",
"fullname":"Paul Cannon (sample)",
"jobtitle":"Ski Instructor",
"annualincome@OData.Community.Display.V1.FormattedValue":"$68,500.00",
"annualincome":68500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"34c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619853\"",
"fullname":"Rene Valdes (sample)",
"jobtitle":"Data Analyst III",
"annualincome@OData.Community.Display.V1.FormattedValue":"$86,000.00",
"annualincome":86000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"38c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619855\"",
"fullname":"Jim Glynn (sample)",
"jobtitle":"Senior International Sales Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$81,400.00",
"annualincome":81400.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"3cc364b2-bf43-e611-80d5-00155da84802"
}
]
}
콘솔 출력
Contacts filtered by fullname and annualincome (<$55,000):
1) Nancy Anderson (sample), Activities Manager, $55,500.00
2) Nancy Anderson (sample), Logistics Specialist, $63,500.00
3) Robert Lyon (sample), Senior Technician, $78,000.00
4) Paul Cannon (sample), Ski Instructor, $68,500.00
5) Rene Valdes (sample), Data Analyst III, $86,000.00
6) Jim Glynn (sample), Senior International Sales Manager, $81,400.00
우선 순위 설정
조건이 평가되는 순서를 설정하려면 괄호를 사용합니다.
이 예제에서는 (sample)을(를) 포함하는 fullname, senior 또는 specialist를 포함하는 jobtitle의 55000보다 큰 annualincome의 전체 연락처 목록을 요청합니다. 우리가 원하는 결과를 얻기 위해 괄호를 사용하여 jobtitle 필터를 그룹화합니다. 모든 연산자는 동일한 우선 순위를 갖기 때문에 괄호를 생략하면 or 연산자의 우선 순위가 and 연산자의 우선 순위와 같아집니다. 필터는 왼쪽에서 오른쪽으로 적용됩니다. 필터에 이러한 설명이 표시되는 순서의 결과가 달라질 수 있습니다. 이 예제에서 쿼리의 모습은 $filter=contains(fullname,'(sample)') and (contains(jobtitle,'senior') or contains(jobtitle,'specialist')) and annualincome gt 55000과 같습니다.
HTTP 요청
GET http://cc_WebAPI_ServiceURI/contacts?$select=fullname,jobtitle,annualincome&$filter=contains(fullname,'(sample)')%20and%20(contains(jobtitle,'senior')%20or%20contains(jobtitle,'specialist'))%20and%20annualincome%20gt%2055000 HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Preference-Applied: odata.maxpagesize=10
Content-Length: 1393
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#contacts(fullname,jobtitle,annualincome)",
"value":[
{
"@odata.etag":"W/\"619845\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Logistics Specialist",
"annualincome@OData.Community.Display.V1.FormattedValue":"$63,500.00",
"annualincome":63500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"28c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619849\"",
"fullname":"Robert Lyon (sample)",
"jobtitle":"Senior Technician",
"annualincome@OData.Community.Display.V1.FormattedValue":"$78,000.00",
"annualincome":78000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"30c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619855\"",
"fullname":"Jim Glynn (sample)",
"jobtitle":"Senior International Sales Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$81,400.00",
"annualincome":81400.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"3cc364b2-bf43-e611-80d5-00155da84802"
}
]
}
콘솔 출력
Contacts filtered by fullname, annualincome and jobtitle (Senior or Specialist):
1) Nancy Anderson (sample), Logistics Specialist, $63,500.00
2) Robert Lyon (sample), Senior Technician, $78,000.00
3) Jim Glynn (sample), Senior International Sales Manager, $81,400.00
결과 순서 설정
$orderby 필터 옵션을 사용하여 결과의 순서를 오름차순 또는 내림차순으로 지정할 수 있습니다. 이 예제에서는 (sample)을 포함하는 fullname의 모든 연락처를 쿼리하고 jobtitle 속성 값을 기준으로 데이터를 오름차순으로 정렬하도록 요청한 다음 $orderby=jobtitle asc, annualincome desc 구문을 사용하여 annualincome 속성 값을 기준으로 내림차순으로 정렬합니다.추가 정보:주문 결과.
HTTP 요청
GET http://cc_WebAPI_ServiceURI/contacts?$select=fullname,jobtitle,annualincome&$filter=contains(fullname,'(sample)')%20&$orderby=jobtitle%20asc,%20annualincome%20desc HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Preference-Applied: odata.maxpagesize=10
Content-Length: 4284
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#contacts(fullname,jobtitle,annualincome)",
"value":[
{
"@odata.etag":"W/\"619847\"",
"fullname":"Scott Konersmann (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$38,000.00",
"annualincome":38000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"2cc364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619843\"",
"fullname":"Maria Cambell (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$31,000.00",
"annualincome":31000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"24c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619841\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Activities Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$55,500.00",
"annualincome":55500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"20c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619718\"",
"fullname":"Yvonne McKay (sample)",
"jobtitle":"Coffee Master",
"annualincome@OData.Community.Display.V1.FormattedValue":"$45,000.00",
"annualincome":45000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"15c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619853\"",
"fullname":"Rene Valdes (sample)",
"jobtitle":"Data Analyst III",
"annualincome@OData.Community.Display.V1.FormattedValue":"$86,000.00",
"annualincome":86000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"38c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619845\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Logistics Specialist",
"annualincome@OData.Community.Display.V1.FormattedValue":"$63,500.00",
"annualincome":63500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"28c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619855\"",
"fullname":"Jim Glynn (sample)",
"jobtitle":"Senior International Sales Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$81,400.00",
"annualincome":81400.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"3cc364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619839\"",
"fullname":"Susanna Stubberod (sample)",
"jobtitle":"Senior Purchaser",
"annualincome@OData.Community.Display.V1.FormattedValue":"$52,000.00",
"annualincome":52000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"1cc364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619849\"",
"fullname":"Robert Lyon (sample)",
"jobtitle":"Senior Technician",
"annualincome@OData.Community.Display.V1.FormattedValue":"$78,000.00",
"annualincome":78000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"30c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619851\"",
"fullname":"Paul Cannon (sample)",
"jobtitle":"Ski Instructor",
"annualincome@OData.Community.Display.V1.FormattedValue":"$68,500.00",
"annualincome":68500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"34c364b2-bf43-e611-80d5-00155da84802"
}
]
}
콘솔 출력
Contacts ordered by jobtitle (ascending) and annualincome (descending):
1) Scott Konersmann (sample), Accounts Manager, $38,000.00
2) Maria Cambell (sample), Accounts Manager, $31,000.00
3) Nancy Anderson (sample), Activities Manager, $55,500.00
4) Yvonne McKay (sample), Coffee Master, $45,000.00
5) Rene Valdes (sample), Data Analyst III, $86,000.00
6) Nancy Anderson (sample), Logistics Specialist, $63,500.00
7) Jim Glynn (sample), Senior International Sales Manager, $81,400.00
8) Susanna Stubberod (sample), Senior Purchaser, $52,000.00
9) Robert Lyon (sample), Senior Technician, $78,000.00
10) Paul Cannon (sample), Ski Instructor, $68,500.00
매개 변수 별칭
필터에 별칭 매개 변수를 사용하여 쉽게 매개 변수를 다시 사용합니다. 매개 변수화된 별칭은 $filter 및 $orderby 옵션에 사용할 수 있습니다. 별칭에 값이 할당되지 않은 경우 null로 간주됩니다. 함수를 호출할 때 매개 변수 별칭을 사용할 수도 있습니다.추가 정보:웹 API 기능 사용, 시스템 쿼리 옵션이 있는 매개 변수 별칭 사용. 예를 들어 주문 결과를 작업할 때 매개 변수를 사용하여 해당 쿼리를 다시 작성할 수 있으며 동일한 출력 결과를 얻게 됩니다.
HTTP 요청
GET http://cc_WebAPI_ServiceURI/contacts?$select=fullname,jobtitle,annualincome&$filter=contains(@p1,'(sample)')%20&$orderby=@p2%20asc,%20@p3%20desc&@p1=fullname&@p2=jobtitle&@p3=annualincome HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Preference-Applied: odata.maxpagesize=10
Content-Length: 4284
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#contacts(fullname,jobtitle,annualincome)",
"value":[
{
"@odata.etag":"W/\"619847\"",
"fullname":"Scott Konersmann (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$38,000.00",
"annualincome":38000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"2cc364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619843\"",
"fullname":"Maria Cambell (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$31,000.00",
"annualincome":31000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"24c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619841\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Activities Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$55,500.00",
"annualincome":55500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"20c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619718\"",
"fullname":"Yvonne McKay (sample)",
"jobtitle":"Coffee Master",
"annualincome@OData.Community.Display.V1.FormattedValue":"$45,000.00",
"annualincome":45000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"15c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619853\"",
"fullname":"Rene Valdes (sample)",
"jobtitle":"Data Analyst III",
"annualincome@OData.Community.Display.V1.FormattedValue":"$86,000.00",
"annualincome":86000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"38c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619845\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Logistics Specialist",
"annualincome@OData.Community.Display.V1.FormattedValue":"$63,500.00",
"annualincome":63500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"28c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619855\"",
"fullname":"Jim Glynn (sample)",
"jobtitle":"Senior International Sales Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$81,400.00",
"annualincome":81400.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"3cc364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619839\"",
"fullname":"Susanna Stubberod (sample)",
"jobtitle":"Senior Purchaser",
"annualincome@OData.Community.Display.V1.FormattedValue":"$52,000.00",
"annualincome":52000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"1cc364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619849\"",
"fullname":"Robert Lyon (sample)",
"jobtitle":"Senior Technician",
"annualincome@OData.Community.Display.V1.FormattedValue":"$78,000.00",
"annualincome":78000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"30c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619851\"",
"fullname":"Paul Cannon (sample)",
"jobtitle":"Ski Instructor",
"annualincome@OData.Community.Display.V1.FormattedValue":"$68,500.00",
"annualincome":68500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"34c364b2-bf43-e611-80d5-00155da84802"
}
]
}
콘솔 출력
Contacts list using parameterized aliases:
1) Scott Konersmann (sample), Accounts Manager, $38,000.00
2) Maria Cambell (sample), Accounts Manager, $31,000.00
3) Nancy Anderson (sample), Activities Manager, $55,500.00
4) Yvonne McKay (sample), Coffee Master, $45,000.00
5) Rene Valdes (sample), Data Analyst III, $86,000.00
6) Nancy Anderson (sample), Logistics Specialist, $63,500.00
7) Jim Glynn (sample), Senior International Sales Manager, $81,400.00
8) Susanna Stubberod (sample), Senior Purchaser, $52,000.00
9) Robert Lyon (sample), Senior Technician, $78,000.00
10) Paul Cannon (sample), Ski Instructor, $68,500.00
결과 제한
필요한 것보다 더 많은 데이터를 반환하는 것은 성능에 부정적으로 작용합니다. 서버는 요청당 최대 5000 엔터티를 반환합니다.$top 쿼리 옵션을 사용하거나 요청 헤더의 odata.maxpagesize를 추가하여 반환되는 결과 수를 제한할 수 있습니다.$top 쿼리 옵션은 결과 집합에서 최상위 수의 엔터티만 반환하고 나머지를 무시합니다. 다음 페이지의 결과를 얻기 위해 odata.maxpagesize 요청 헤더는 @odata.nextLink 속성을 사용하여 페이지당 반환될 엔터티 수를 지정합니다.odata.maxpagesize에 대한 자세한 내용은 페이지 구분의 해당 섹션과 반환된 엔터티 수에 대한 제한를 참고하십시오.
최상위 결과
$top 쿼리 옵션을 적용하여 (sample)을(를) 포함하는 fullname의 처음 다섯 개의 연락처로 기본 쿼리 작업을 제한할 수 있습니다. 이 경우 요청에서 실제로 적어도 10개의 결과를 생성하지만 처음 5개 항목만 응답에 반환됩니다.
HTTP 요청
GET http://cc_WebAPI_ServiceURI/contacts?$select=fullname,jobtitle,annualincome&$filter=contains(fullname,'(sample)')&$top=5 HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Content-Length: 2209
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#contacts(fullname,jobtitle,annualincome)",
"value":[
{
"@odata.etag":"W/\"619718\"",
"fullname":"Yvonne McKay (sample)",
"jobtitle":"Coffee Master",
"annualincome@OData.Community.Display.V1.FormattedValue":"$45,000.00",
"annualincome":45000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"15c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619839\"",
"fullname":"Susanna Stubberod (sample)",
"jobtitle":"Senior Purchaser",
"annualincome@OData.Community.Display.V1.FormattedValue":"$52,000.00",
"annualincome":52000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"1cc364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619841\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Activities Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$55,500.00",
"annualincome":55500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"20c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619843\"",
"fullname":"Maria Cambell (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$31,000.00",
"annualincome":31000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"24c364b2-bf43-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"619845\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Logistics Specialist",
"annualincome@OData.Community.Display.V1.FormattedValue":"$63,500.00",
"annualincome":63500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"28c364b2-bf43-e611-80d5-00155da84802"
}
]
}
콘솔 출력
Contacts top 5 results:
1) Yvonne McKay (sample), Coffee Master, $45,000.00
2) Susanna Stubberod (sample), Senior Purchaser, $52,000.00
3) Nancy Anderson (sample), Activities Manager, $55,500.00
4) Maria Cambell (sample), Accounts Manager, $31,000.00
5) Nancy Anderson (sample), Logistics Specialist, $63,500.00
결과 개수
컬렉션 값 속성의 레코드 수 또는 필터에서 일치하는 엔터티 수만큼 결과를 얻을 수 있습니다. 원하는 수의 결과를 얻으면 가능한 엔터티 개수가 결과에 나타납니다. 그러나 그 이상의 결과가 있더라도 Dynamics 365 서버는 최대 5000개를 반환합니다. 이 예제에서는 Senior 또는 Manager가 포함된 jobtitle로 필터를 설정하고 결과에 $count 또한 요청했습니다. 응답에 @odata.count 속성의 개수뿐만 아니라 쿼리 결과의 개수도 포함됩니다.추가 정보:엔터티 수 검색.
HTTP 요청
GET http://cc_WebAPI_ServiceURI/contacts?$select=fullname,jobtitle,annualincome&$filter=contains(jobtitle,'senior')%20or%20contains(jobtitle,%20'manager')&$count=true HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Preference-Applied: odata.maxpagesize=10
Content-Length: 2654
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#contacts(fullname,jobtitle,annualincome)",
"@odata.count":6,
"value":[
{
"@odata.etag":"W/\"620258\"",
"fullname":"Susanna Stubberod (sample)",
"jobtitle":"Senior Purchaser",
"annualincome@OData.Community.Display.V1.FormattedValue":"$52,000.00",
"annualincome":52000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"bf48fdee-c143-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620260\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Activities Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$55,500.00",
"annualincome":55500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"c348fdee-c143-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620262\"",
"fullname":"Maria Cambell (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$31,000.00",
"annualincome":31000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"c748fdee-c143-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620266\"",
"fullname":"Scott Konersmann (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$38,000.00",
"annualincome":38000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"cf48fdee-c143-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620268\"",
"fullname":"Robert Lyon (sample)",
"jobtitle":"Senior Technician",
"annualincome@OData.Community.Display.V1.FormattedValue":"$78,000.00",
"annualincome":78000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"d348fdee-c143-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620274\"",
"fullname":"Jim Glynn (sample)",
"jobtitle":"Senior International Sales Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$81,400.00",
"annualincome":81400.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"df48fdee-c143-e611-80d5-00155da84802"
}
]
}
콘솔 출력
6 contacts have either 'Manager' or 'Senior' designation in their jobtitle.
Manager or Senior:
1) Susanna Stubberod (sample), Senior Purchaser, $52,000.00
2) Nancy Anderson (sample), Activities Manager, $55,500.00
3) Maria Cambell (sample), Accounts Manager, $31,000.00
4) Scott Konersmann (sample), Accounts Manager, $38,000.00
5) Robert Lyon (sample), Senior Technician, $78,000.00
6) Jim Glynn (sample), Senior International Sales Manager, $81,400.00
페이지 구분
많은 수의 엔터티를 반환하는 쿼리에 대한 결과의 순차 하위 집합을 검색하려면 $top 대신 odata.maxpagesize를 사용합니다.추가 정보:페이지에 반환할 엔터티 수를 지정합니다..
여기에서는 $count를 요청하고 odata.maxpagesize를 4로 설정합니다. 이 필터는 10개의 연락처와 일치하지만 여기서는 한 번에 4개만 검색합니다. 또한 개수와 최대 페이지 크기를 사용하여 전체 페이지 수를 계산합니다. 첫 페이지의 결과가 이 요청에 반환됩니다.
HTTP 요청
GET http://cc_WebAPI_ServiceURI/contacts?$select=fullname,jobtitle,annualincome&$filter=contains(fullname,'(sample)')&$count=true HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=4, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Preference-Applied: odata.maxpagesize=4
Content-Length: 2294
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#contacts(fullname,jobtitle,annualincome)",
"@odata.count":10,
"value":[
{
"@odata.etag":"W/\"620138\"",
"fullname":"Yvonne McKay (sample)",
"jobtitle":"Coffee Master",
"annualincome@OData.Community.Display.V1.FormattedValue":"$45,000.00",
"annualincome":45000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"b848fdee-c143-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620258\"",
"fullname":"Susanna Stubberod (sample)",
"jobtitle":"Senior Purchaser",
"annualincome@OData.Community.Display.V1.FormattedValue":"$52,000.00",
"annualincome":52000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"bf48fdee-c143-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620260\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Activities Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$55,500.00",
"annualincome":55500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"c348fdee-c143-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620262\"",
"fullname":"Maria Cambell (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$31,000.00",
"annualincome":31000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"c748fdee-c143-e611-80d5-00155da84802"
}
],
"@odata.nextLink":"http://cc_WebAPI_ServiceURI/contacts?$select=fullname,jobtitle,annualincome&$filter=contains(fullname,'(sample)')&$count=true&$skiptoken=%3Ccookie%20pagenumber=%222%22%20pagingcookie=%22%253ccookie%2520page%253d%25221%2522%253e%253ccontactid%2520last%253d%2522%257bC748FDEE-C143-E611-80D5-00155DA84802%257d%2522%2520first%253d%2522%257bB848FDEE-C143-E611-80D5-00155DA84802%257d%2522%2520%252f%253e%253c%252fcookie%253e%22%20istracking=%22False%22%20/%3E"
}
콘솔 출력
Contacts total: 10 Contacts per page: 4.
Page 1 of 3:
1) Yvonne McKay (sample), Coffee Master, $45,000.00
2) Susanna Stubberod (sample), Senior Purchaser, $52,000.00
3) Nancy Anderson (sample), Activities Manager, $55,500.00
4) Maria Cambell (sample), Accounts Manager, $31,000.00
2페이지를 검색하려면 @odata.nextLink 속성 값과 함께 GET 요청을 사용합니다.
HTTP 요청
GET http://cc_WebAPI_ServiceURI/contacts?$select=fullname,jobtitle,annualincome&$filter=contains(fullname,'(sample)')&$count=true&$skiptoken=%3Ccookie%20pagenumber=%222%22%20pagingcookie=%22%253ccookie%2520page%253d%25221%2522%253e%253ccontactid%2520last%253d%2522%257bC748FDEE-C143-E611-80D5-00155DA84802%257d%2522%2520first%253d%2522%257bB848FDEE-C143-E611-80D5-00155DA84802%257d%2522%2520%252f%253e%253c%252fcookie%253e%22%20istracking=%22False%22%20/%3E HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=4, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Preference-Applied: odata.maxpagesize=4
Content-Length: 2294
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#contacts(fullname,jobtitle,annualincome)",
"@odata.count":10,
"value":[
{
"@odata.etag":"W/\"620264\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Logistics Specialist",
"annualincome@OData.Community.Display.V1.FormattedValue":"$63,500.00",
"annualincome":63500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"cb48fdee-c143-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620266\"",
"fullname":"Scott Konersmann (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$38,000.00",
"annualincome":38000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"cf48fdee-c143-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620268\"",
"fullname":"Robert Lyon (sample)",
"jobtitle":"Senior Technician",
"annualincome@OData.Community.Display.V1.FormattedValue":"$78,000.00",
"annualincome":78000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"d348fdee-c143-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620270\"",
"fullname":"Paul Cannon (sample)",
"jobtitle":"Ski Instructor",
"annualincome@OData.Community.Display.V1.FormattedValue":"$68,500.00",
"annualincome":68500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"d748fdee-c143-e611-80d5-00155da84802"
}
],
"@odata.nextLink":"http://cc_WebAPI_ServiceURI/contacts?$select=fullname,jobtitle,annualincome&$filter=contains(fullname,'(sample)')&$count=true&$skiptoken=%3Ccookie%20pagenumber=%223%22%20pagingcookie=%22%253ccookie%2520page%253d%25222%2522%253e%253ccontactid%2520last%253d%2522%257bD748FDEE-C143-E611-80D5-00155DA84802%257d%2522%2520first%253d%2522%257bCB48FDEE-C143-E611-80D5-00155DA84802%257d%2522%2520%252f%253e%253c%252fcookie%253e%22%20istracking=%22False%22%20/%3E"
}
콘솔 출력
Page 2 of 3:
1) Nancy Anderson (sample), Logistics Specialist, $63,500.00
2) Scott Konersmann (sample), Accounts Manager, $38,000.00
3) Robert Lyon (sample), Senior Technician, $78,000.00
4) Paul Cannon (sample), Ski Instructor, $68,500.00
결과 확장
관련된 엔터티에 대한 정보를 검색하려면 탐색 속성의 $expand 쿼리 옵션을 사용합니다.추가 정보:탐색 속성을 확장하여 관련 엔터티 검색.
단일 값 탐색 속성 확장
단일 값 탐색 속성은 다 대 일 관계를 나타냅니다. 여기의 샘플 데이터에서 거래처는 primarycontactid 특성의 연락처와 관계가 있습니다. 이 관계에서 거래처는 기본 연락처를 하나만 가질 수 있습니다.account EntityType을 사용하여 거래처에 대한 정보 및 거래처의 기본 연락처에 대해 확장된 정보를 가져오는 쿼리를 만들 수 있습니다.
HTTP 요청
GET http://cc_WebAPI_ServiceURI/accounts(b2546951-c543-e611-80d5-00155da84802)?$select=name&$expand=primarycontactid($select=fullname,jobtitle,annualincome) HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Preference-Applied: odata.maxpagesize=10
Content-Length: 700
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#accounts(name,primarycontactid,primarycontactid(fullname,jobtitle,annualincome))/$entity",
"@odata.etag":"W/\"620641\"",
"name":"Contoso, Ltd. (sample)",
"accountid":"b2546951-c543-e611-80d5-00155da84802",
"primarycontactid":{
"@odata.etag":"W/\"620534\"",
"fullname":"Yvonne McKay (sample)",
"jobtitle":"Coffee Master",
"annualincome@OData.Community.Display.V1.FormattedValue":"$45,000.00",
"annualincome":45000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"b3546951-c543-e611-80d5-00155da84802"
}
}
콘솔 출력
Account 'Contoso, Ltd. (sample)' has the following primary contact person:
Fullname: 'Yvonne McKay (sample)'
Jobtitle: 'Coffee Master'
Annualincome: '45000'
파트너 속성 확장
각 탐색 속성은 이에 해당하는 "파트너" 속성이 있습니다. 탐색 속성과 파트너 속성이 연결되면 이러한 연결을 통해 정보를 검색할 수 있습니다. 사용하는 특성은 쿼리에 대한 기본 엔터티에 따라 다릅니다. 예를 들어, 이전 작업에서 account EntityType에 대한 쿼리를 만들고 이 기본 연락처에 대한 추가 정보를 원했습니다.primarycontactid 특성을 사용하여 이 작업을 수행했습니다.account EntityType을 조회할 때 Single-valued navigation properties 섹션 아래에서 primarycontactid에 대한 파트너 속성이 contact EntityType에서 찾을 수 있는 account_primary_contact 컬렉션 값 탐색 속성임을 알 수 있습니다.
연락처에 대한 쿼리를 작성하면 account_primary_contact 특성을 확장하여 해당 연락처가 기본 연락처인 거래처에 대한 정보를 가져올 수 있습니다. 샘플 데이터에서 Yvonne McKay (sample)는 한 거래처에 대한 기본 연락처입니다. 그러나, 그녀는 다른 거래처에 대한 기본 연락처로 지정될 가능성이 있습니다.account_primary_contact 속성이 다 대 일 관계 결과를 가지기 때문에 결과는 거래처 엔터티의 배열로 반환됩니다.
HTTP 요청
GET http://cc_WebAPI_ServiceURI/contacts(b3546951-c543-e611-80d5-00155da84802)?$select=fullname,jobtitle,annualincome&$expand=account_primary_contact($select=name) HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Preference-Applied: odata.maxpagesize=10
Content-Length: 737
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#contacts(fullname,jobtitle,annualincome,account_primary_contact,account_primary_contact(name))/$entity",
"@odata.etag":"W/\"620534\"",
"fullname":"Yvonne McKay (sample)",
"jobtitle":"Coffee Master",
"annualincome@OData.Community.Display.V1.FormattedValue":"$45,000.00",
"annualincome":45000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"b3546951-c543-e611-80d5-00155da84802",
"account_primary_contact":[
{
"@odata.etag":"W/\"620919\"",
"name":"Contoso, Ltd. (sample)",
"accountid":"b2546951-c543-e611-80d5-00155da84802"
}
]
}
콘솔 출력
Contact 'Yvonne McKay (sample)' is the primary contact for the following accounts:
1) Contoso, Ltd. (sample)
컬렉션 값 탐색 속성 확장
컬렉션 값 탐색 속성은 일 대 다 또는 다 대 다 관계를 지원합니다. 예를 들어 여기의 샘플 데이터에서 거래처는 contact_customer_accounts 특성의 여러 연락처와 관계가 있습니다.
account EntityType을 사용하여 거래처에 대한 정보를 가져오는 쿼리를 만들고 이 연락처의 정보를 확장할 수 있습니다. 이 경우에 Contoso, Ltd. (sample)는 contact_customer_accounts 컬렉션 값 탐색 속성을 통해 다른 9개의 연락처와 연결됩니다.
HTTP 요청
GET http://cc_WebAPI_ServiceURI/accounts(86546951-c543-e611-80d5-00155da84802)?$select=name&$expand=contact_customer_accounts($select=fullname,jobtitle,annualincome) HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Preference-Applied: odata.maxpagesize=10
Content-Length: 4073
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#accounts(name,contact_customer_accounts,contact_customer_accounts(fullname,jobtitle,annualincome))/$entity",
"@odata.etag":"W/\"620921\"",
"name":"Contoso, Ltd. (sample)",
"accountid":"86546951-c543-e611-80d5-00155da84802",
"contact_customer_accounts":[
{
"@odata.etag":"W/\"620847\"",
"fullname":"Susanna Stubberod (sample)",
"jobtitle":"Senior Purchaser",
"annualincome@OData.Community.Display.V1.FormattedValue":"$52,000.00",
"annualincome":52000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"8e546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620849\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Activities Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$55,500.00",
"annualincome":55500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"92546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620851\"",
"fullname":"Maria Cambell (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$31,000.00",
"annualincome":31000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"96546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620853\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Logistics Specialist",
"annualincome@OData.Community.Display.V1.FormattedValue":"$63,500.00",
"annualincome":63500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"9a546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620855\"",
"fullname":"Scott Konersmann (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$38,000.00",
"annualincome":38000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"9e546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620857\"",
"fullname":"Robert Lyon (sample)",
"jobtitle":"Senior Technician",
"annualincome@OData.Community.Display.V1.FormattedValue":"$78,000.00",
"annualincome":78000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"a2546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620859\"",
"fullname":"Paul Cannon (sample)",
"jobtitle":"Ski Instructor",
"annualincome@OData.Community.Display.V1.FormattedValue":"$68,500.00",
"annualincome":68500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"a6546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620861\"",
"fullname":"Rene Valdes (sample)",
"jobtitle":"Data Analyst III",
"annualincome@OData.Community.Display.V1.FormattedValue":"$86,000.00",
"annualincome":86000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"aa546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620863\"",
"fullname":"Jim Glynn (sample)",
"jobtitle":"Senior International Sales Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$81,400.00",
"annualincome":81400.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"ae546951-c543-e611-80d5-00155da84802"
}
]
}
콘솔 출력
Account 'Contoso, Ltd. (sample)' has the following contact customers:
1) Susanna Stubberod (sample), Senior Purchaser, $52,000.00
2) Nancy Anderson (sample), Activities Manager, $55,500.00
3) Maria Cambell (sample), Accounts Manager, $31,000.00
4) Nancy Anderson (sample), Logistics Specialist, $63,500.00
5) Scott Konersmann (sample), Accounts Manager, $38,000.00
6) Robert Lyon (sample), Senior Technician, $78,000.00
7) Paul Cannon (sample), Ski Instructor, $68,500.00
8) Rene Valdes (sample), Data Analyst III, $86,000.00
9) Jim Glynn (sample), Senior International Sales Manager, $81,400.00
여러 탐색 속성 확장
쿼리에 필요한 만큼 탐색 속성을 확장할 수 있습니다. 그러나 $expand 옵션은 한 수준만을 확장할 수 있습니다.
이 예제는 account EntityType의 primarycontactid, contact_customer_accounts, 그리고 Account_Tasks 탐색 속성으로 확장됩니다. 쿼리는 거래처와 연락처 컬렉션 및 작업 컬렉션의 두 컬렉션에 대한 정보가 포함된 응답을 반환합니다. 샘플 코드는 이러한 컬렉션을 별도로 처리합니다.
HTTP 요청
GET http://cc_WebAPI_ServiceURI/accounts(86546951-c543-e611-80d5-00155da84802)?$select=name&$expand=primarycontactid($select=fullname,jobtitle,annualincome),contact_customer_accounts($select=fullname,jobtitle,annualincome),Account_Tasks($select=subject,description) HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Preference-Applied: odata.maxpagesize=10
Content-Length: 5093
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#accounts(name,primarycontactid,contact_customer_accounts,Account_Tasks,primarycontactid(fullname,jobtitle,annualincome),contact_customer_accounts(fullname,jobtitle,annualincome),Account_Tasks(subject,description))/$entity",
"@odata.etag":"W/\"620921\"",
"name":"Contoso, Ltd. (sample)",
"accountid":"86546951-c543-e611-80d5-00155da84802",
"primarycontactid":{
"@odata.etag":"W/\"620726\"",
"fullname":"Yvonne McKay (sample)",
"jobtitle":"Coffee Master",
"annualincome@OData.Community.Display.V1.FormattedValue":"$45,000.00",
"annualincome":45000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"87546951-c543-e611-80d5-00155da84802"
},
"contact_customer_accounts":[
{
"@odata.etag":"W/\"620847\"",
"fullname":"Susanna Stubberod (sample)",
"jobtitle":"Senior Purchaser",
"annualincome@OData.Community.Display.V1.FormattedValue":"$52,000.00",
"annualincome":52000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"8e546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620849\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Activities Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$55,500.00",
"annualincome":55500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"92546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620851\"",
"fullname":"Maria Cambell (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$31,000.00",
"annualincome":31000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"96546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620853\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Logistics Specialist",
"annualincome@OData.Community.Display.V1.FormattedValue":"$63,500.00",
"annualincome":63500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"9a546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620855\"",
"fullname":"Scott Konersmann (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$38,000.00",
"annualincome":38000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"9e546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620857\"",
"fullname":"Robert Lyon (sample)",
"jobtitle":"Senior Technician",
"annualincome@OData.Community.Display.V1.FormattedValue":"$78,000.00",
"annualincome":78000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"a2546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620859\"",
"fullname":"Paul Cannon (sample)",
"jobtitle":"Ski Instructor",
"annualincome@OData.Community.Display.V1.FormattedValue":"$68,500.00",
"annualincome":68500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"a6546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620861\"",
"fullname":"Rene Valdes (sample)",
"jobtitle":"Data Analyst III",
"annualincome@OData.Community.Display.V1.FormattedValue":"$86,000.00",
"annualincome":86000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"aa546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620863\"",
"fullname":"Jim Glynn (sample)",
"jobtitle":"Senior International Sales Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$81,400.00",
"annualincome":81400.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"ae546951-c543-e611-80d5-00155da84802"
}
],
"Account_Tasks":[
{
"@odata.etag":"W/\"620840\"",
"subject":"Task 1",
"description":"Task 1 description",
"activityid":"8b546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620842\"",
"subject":"Task 2",
"description":"Task 2 description",
"activityid":"8c546951-c543-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"620844\"",
"subject":"Task 3",
"description":"Task 3 description",
"activityid":"8d546951-c543-e611-80d5-00155da84802"
}
]
}
콘솔 출력
-- Expanding multiple property types in one request --
Account 'Contoso, Ltd. (sample)' has the following primary contact person:
Fullname: 'Yvonne McKay (sample)'
Jobtitle: 'Coffee Master'
Annualincome: '45000'
Account 'Contoso, Ltd. (sample)' has the following related contacts:
1) Susanna Stubberod (sample), Senior Purchaser, $52,000.00
2) Nancy Anderson (sample), Activities Manager, $55,500.00
3) Maria Cambell (sample), Accounts Manager, $31,000.00
4) Nancy Anderson (sample), Logistics Specialist, $63,500.00
5) Scott Konersmann (sample), Accounts Manager, $38,000.00
6) Robert Lyon (sample), Senior Technician, $78,000.00
7) Paul Cannon (sample), Ski Instructor, $68,500.00
8) Rene Valdes (sample), Data Analyst III, $86,000.00
9) Jim Glynn (sample), Senior International Sales Manager, $81,400.00
Account 'Contoso, Ltd. (sample)' has the following tasks:
1) Task 1, Task 1 description
2) Task 2, Task 2 description
3) Task 3, Task 3 description
FetchXML 쿼리
쿼리 필터 작업 외에도 웹 API는 FetchXML 쿼리도 지원합니다. FetchXML은 집계를 수행하는 쿼리 및 추가 옵션을 정의하는 다른 방법을 제공합니다.추가 정보:FetchXML을 사용하여 쿼리 작성
FetchXML을 사용하려면 쿼리를 나타내는 문자열을 작성해야 합니다. 쿼리 문자열이 FetchXML schema를 준수하는지 확인하십시오. URL에 문자열을 포함하기 전에 문자열을 URL 인코딩해야 합니다.
$select, $filter, 및 $orderby 같은 일반적으로 정의하는 쿼리 옵션은 이제 모두 XML에서 정의됩니다. 이 작업에서 fullname이 (sample)과(와) 일치하는 모든 연락처를 쿼리하고 결과를 fullname을 기준으로 내림차순으로 정렬합니다. 이 쿼리에 대한 XML입니다.
<fetch mapping="logical" output-format="xml-platform" version="1.0" distinct="false">
<entity name="contact">
<attribute name="fullname" />
<attribute name="jobtitle" />
<attribute name="annualincome" />
<order descending="true"
attribute="fullname" />
<filter type="and">
<condition value="%(sample)%"
attribute="fullname"
operator="like" />
</filter>
</entity>
</fetch>
HTTP 요청
요청 쿼리 문자열 인코딩된 형식으로 서버에 보내집니다. 인코딩된 머리글은 다음과 같습니다.
GET http://cc_WebAPI_ServiceURI/contacts?fetchXml=%253Cfetch%2520mapping%253D%2522logical%2522%2520output-format%253D%2522xml-platform%2522%2520version%253D%25221.0%2522%2520distinct%253D%2522false%2522%253E%2520%2520%2520%253Centity%2520name%253D%2522contact%2522%253E%2520%2520%2520%2520%2520%253Cattribute%2520name%253D%2522fullname%2522%2520%252F%253E%2520%2520%2520%2520%2520%253Cattribute%2520name%253D%2522jobtitle%2522%2520%252F%253E%2520%2520%2520%2520%2520%253Cattribute%2520name%253D%2522annualincome%2522%2520%252F%253E%2520%2520%2520%2520%2520%253Corder%2520descending%253D%2522true%2522%2520attribute%253D%2522fullname%2522%2520%252F%253E%2520%2520%2520%2520%2520%253Cfilter%2520type%253D%2522and%2522%253E%2520%2520%2520%2520%2520%2520%2520%253Ccondition%2520value%253D%2522%2525(sample)%2525%2522%2520attribute%253D%2522fullname%2522%2520operator%253D%2522like%2522%2520%252F%253E%2520%2520%2520%2520%2520%253C%252Ffilter%253E%2520%2520%2520%253C%252Fentity%253E%2520%253C%252Ffetch%253E%2520 HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Content-Length: 4345
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#contacts(fullname,jobtitle,annualincome,_transactioncurrencyid_value,transactioncurrencyid,contactid)",
"value":[
{
"@odata.etag":"W/\"621502\"",
"fullname":"Yvonne McKay (sample)",
"jobtitle":"Coffee Master",
"annualincome@OData.Community.Display.V1.FormattedValue":"$45,000.00",
"annualincome":45000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"9255b257-c843-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"621627\"",
"fullname":"Susanna Stubberod (sample)",
"jobtitle":"Senior Purchaser",
"annualincome@OData.Community.Display.V1.FormattedValue":"$52,000.00",
"annualincome":52000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"9955b257-c843-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"621635\"",
"fullname":"Scott Konersmann (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$38,000.00",
"annualincome":38000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"a955b257-c843-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"621637\"",
"fullname":"Robert Lyon (sample)",
"jobtitle":"Senior Technician",
"annualincome@OData.Community.Display.V1.FormattedValue":"$78,000.00",
"annualincome":78000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"ad55b257-c843-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"621641\"",
"fullname":"Rene Valdes (sample)",
"jobtitle":"Data Analyst III",
"annualincome@OData.Community.Display.V1.FormattedValue":"$86,000.00",
"annualincome":86000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"b555b257-c843-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"621639\"",
"fullname":"Paul Cannon (sample)",
"jobtitle":"Ski Instructor",
"annualincome@OData.Community.Display.V1.FormattedValue":"$68,500.00",
"annualincome":68500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"b155b257-c843-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"621629\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Activities Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$55,500.00",
"annualincome":55500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"9d55b257-c843-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"621633\"",
"fullname":"Nancy Anderson (sample)",
"jobtitle":"Logistics Specialist",
"annualincome@OData.Community.Display.V1.FormattedValue":"$63,500.00",
"annualincome":63500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"a555b257-c843-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"621631\"",
"fullname":"Maria Cambell (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$31,000.00",
"annualincome":31000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"a155b257-c843-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"621643\"",
"fullname":"Jim Glynn (sample)",
"jobtitle":"Senior International Sales Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$81,400.00",
"annualincome":81400.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"b955b257-c843-e611-80d5-00155da84802"
}
]
}
콘솔 출력
Contacts Fetched by fullname containing '(sample)':
1) Yvonne McKay (sample), Coffee Master, $45,000.00
2) Susanna Stubberod (sample), Senior Purchaser, $52,000.00
3) Scott Konersmann (sample), Accounts Manager, $38,000.00
4) Robert Lyon (sample), Senior Technician, $78,000.00
5) Rene Valdes (sample), Data Analyst III, $86,000.00
6) Paul Cannon (sample), Ski Instructor, $68,500.00
7) Nancy Anderson (sample), Activities Manager, $55,500.00
8) Nancy Anderson (sample), Logistics Specialist, $63,500.00
9) Maria Cambell (sample), Accounts Manager, $31,000.00
10) Jim Glynn (sample), Senior International Sales Manager, $81,400.00
FetchXML 페이지 매기기
FetchXML 페이징 처리 방식은 쿼리 필터 처리 방법과 다릅니다. FetchXML에서는 페이지당 반환할 결과의 수를 나타내는 count 특성을 지정할 수 있습니다. 같은 요청에서 page 특성을 사용하여 원하는 페이지 번호를 지정할 수 있습니다. 이 작업은 이전 FetchXML 샘플에 3페이지를 요청합니다. 샘플 데이터에 따르면 해야 결과에 10개의 연락처가 표시되어야 합니다. 각 페이지당 4개의 엔터티가 표시되는 경우 3개 페이지가 나타나야 합니다. 3페이지는 두 엔터티를 포함해야 합니다. 그렇다면 4페이지를 요청하면 시스템에서 0개의 결과를 반환할 것입니다.
<fetch mapping="logical"
output-format="xml-platform"
version="1.0"
distinct="false"
page="3"
count="4">
<entity name="contact">
<attribute name="fullname" />
<attribute name="jobtitle" />
<attribute name="annualincome" />
<order descending="true"
attribute="fullname" />
<filter type="and">
<condition value="%(sample)%"
attribute="fullname"
operator="like" />
</filter>
</entity>
</fetch>
HTTP 요청
요청 쿼리 문자열 인코딩된 형식으로 서버에 보내집니다. 인코딩된 머리글은 다음과 같습니다.
GET http://cc_WebAPI_ServiceURI/contacts?fetchXml=%253Cfetch%2520mapping%253D%2522logical%2522%2520output-format%253D%2522xml-platform%2522%2520version%253D%25221.0%2522%2520distinct%253D%2522false%2522%2520page%253D%25223%2522%2520count%253D%25224%2522%253E%2520%2520%2520%253Centity%2520name%253D%2522contact%2522%253E%2520%2520%2520%2520%2520%253Cattribute%2520name%253D%2522fullname%2522%2520%252F%253E%2520%2520%2520%2520%2520%253Cattribute%2520name%253D%2522jobtitle%2522%2520%252F%253E%2520%2520%2520%2520%2520%253Cattribute%2520name%253D%2522annualincome%2522%2520%252F%253E%2520%2520%2520%2520%2520%253Corder%2520descending%253D%2522true%2522%2520attribute%253D%2522fullname%2522%2520%252F%253E%2520%2520%2520%2520%2520%253Cfilter%2520type%253D%2522and%2522%253E%2520%2520%2520%2520%2520%2520%2520%253Ccondition%2520value%253D%2522%2525(sample)%2525%2522%2520attribute%253D%2522fullname%2522%2520operator%253D%2522like%2522%2520%252F%253E%2520%2520%2520%2520%2520%253C%252Ffilter%253E%2520%2520%2520%253C%252Fentity%253E%2520%253C%252Ffetch%253E%2520 HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Content-Length: 1037
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#contacts(fullname,jobtitle,annualincome,_transactioncurrencyid_value,transactioncurrencyid,contactid)",
"value":[
{
"@odata.etag":"W/\"621631\"",
"fullname":"Maria Cambell (sample)",
"jobtitle":"Accounts Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$31,000.00",
"annualincome":31000.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"a155b257-c843-e611-80d5-00155da84802"
},
{
"@odata.etag":"W/\"621643\"",
"fullname":"Jim Glynn (sample)",
"jobtitle":"Senior International Sales Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$81,400.00",
"annualincome":81400.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802",
"contactid":"b955b257-c843-e611-80d5-00155da84802"
}
]
}
콘솔 출력
Contacts Fetched by fullname containing '(sample)' - Page 3:
1) Maria Cambell (sample), Accounts Manager, $31,000.00
2) Jim Glynn (sample), Senior International Sales Manager, $81,400.00
미리 정의된 쿼리
웹 API를 사용하여 미리 정의된 쿼리를 실행할 수 있습니다.추가 정보:미리 정의된 쿼리 검색 및 실행.
저장된 쿼리
이 작업에서는 활성 거래처라는 이름으로 저장된 쿼리의 savedqueryid GUID에 대해 요청합니다. 그 다음 GUID와 savedQuery 매개 변수를 사용하여 활성 거래처 목록을 쿼리합니다.
저장된 쿼리의 GUID 가져오기
HTTP 요청
GET http://cc_WebAPI_ServiceURI/savedqueries?$select=name,savedqueryid&$filter=name%20eq%20'Active%20Accounts' HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
Referer: https://localhost:1469/WebAPIQuery.html
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Content-Length: 251
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#savedqueries(name,savedqueryid)",
"value":[
{
"@odata.etag":"W/\"443067\"",
"name":"Active Accounts",
"savedqueryid":"00000000-0000-0000-00aa-000010001002"
}
]
}
savedQuery 매개 변수를 사용하는 저장된 쿼리의 콘텐츠 가져오기
HTTP 요청
GET http://cc_WebAPI_ServiceURI/accounts?savedQuery=00000000-0000-0000-00aa-000010001002 HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
REQ_ID: 2bc532c4-d445-44cd-adae-1909a616d6bc
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
Content-Length: 446
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#accounts(name,_primarycontactid_value,primarycontactid,accountid)",
"value":[
{
"@odata.etag":"W/\"621613\"",
"name":"Contoso, Ltd. (sample)",
"_primarycontactid_value@OData.Community.Display.V1.FormattedValue":"Yvonne McKay (sample)",
"_primarycontactid_value":"9255b257-c843-e611-80d5-00155da84802",
"accountid":"9155b257-c843-e611-80d5-00155da84802"
}
]
}
콘솔 출력
-- Saved Query --
Saved Query (Active Accounts):
1) Contoso, Ltd. (sample)
사용자 쿼리
이 샘플에서는 사용자 쿼리를 만들고, 실행한 다음 시스템에서 삭제합니다. 이 사용자 쿼리는 fullname에 (sample)이(가) 포함되고 jobtitle에 manager가 포함되며 annualincome이 55000보다 큰 모든 연락처에 대한 요청입니다. 예제 데이터에서는 이 쿼리와 일치하는 연락처가 두 개입니다.
사용자 쿼리의 GUID 가져오기
HTTP 요청
GET http://cc_WebAPI_ServiceURI/userqueries?$select=name,userqueryid,&$filter=name%20eq%20'My%20User%20Query' HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Referer: https://localhost:1469/WebAPIQuery.html
HTTP 응답
Pragma: no-cache
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Content-Length: 246
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#userqueries(name,userqueryid)",
"value":[
{
"@odata.etag":"W/\"621698\"",
"name":"My User Query",
"userqueryid":"7ec390ab-c943-e611-80d5-00155da84802"
}
]
}
userQuery 매개 변수로 GUID 값을 전달하는 사용자 쿼리 콘텐츠 가져오기
HTTP 요청
GET http://cc_WebAPI_ServiceURI/contacts?userQuery=7ec390ab-c943-e611-80d5-00155da84802 HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
Prefer: odata.maxpagesize=10, odata.include-annotations=OData.Community.Display.V1.FormattedValue
HTTP 응답
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Content-Length: 1040
{
"@odata.context":"http://cc_WebAPI_ServiceURI/$metadata#contacts(fullname,contactid,jobtitle,annualincome,_transactioncurrencyid_value,transactioncurrencyid)",
"value":[
{
"@odata.etag":"W/\"621643\"",
"fullname":"Jim Glynn (sample)",
"contactid":"b955b257-c843-e611-80d5-00155da84802",
"jobtitle":"Senior International Sales Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$81,400.00",
"annualincome":81400.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802"
},
{
"@odata.etag":"W/\"621629\"",
"fullname":"Nancy Anderson (sample)",
"contactid":"9d55b257-c843-e611-80d5-00155da84802",
"jobtitle":"Activities Manager",
"annualincome@OData.Community.Display.V1.FormattedValue":"$55,500.00",
"annualincome":55500.0000,
"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue":"US Dollar",
"_transactioncurrencyid_value":"518c78c9-d3f6-e511-80d0-00155da84802"
}
]
}
콘솔 출력
-- User Query --
Saved User Query:
1) Jim Glynn (sample), Senior International Sales Manager, $81,400.00
2) Nancy Anderson (sample), Activities Manager, $55,500.00
참고 항목
Microsoft Dynamics 365 웹 API 사용
웹 API를 사용하여 데이터 쿼리
미리 정의된 쿼리 검색 및 실행
웹 API 쿼리 데이터 샘플(C#)
웹 API 쿼리 데이터 샘플(클라이언트 쪽 JavaScript)
Microsoft Dynamics 365
© 2017 Microsoft. All rights reserved. 저작권 정보