Skip to content

Commit 30c2817

Browse files
committed
check
1 parent ee61363 commit 30c2817

File tree

1 file changed

+223
-0
lines changed

1 file changed

+223
-0
lines changed

powerapps-docs/developer/model-driven-apps/best-practices/business-logic/do-not-use-odata-v2-endpoint.md

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,180 @@ The following table connects related areas for the Organization Data Service and
102102

103103
This section highlights the differences between using the Organization Data Service and the Web API.
104104

105+
### Query records
106+
107+
These examples show the differences between the Organization Data Service and the Web API when querying records.
108+
109+
#### [Organization Data Service](#tab/odatav2)
110+
111+
**Request**
112+
113+
```http
114+
GET [Organization URI]/XRMServices/2011/OrganizationData.svc/AccountSet?$select=OwnershipCode,PrimaryContactId,OpenDeals_Date,Telephone1,NumberOfEmployees,Name,AccountNumber,DoNotPhone,IndustryCode&$filter=PrimaryContactId/Id ne null&$top=2 HTTP/1.1
115+
Accept: application/json
116+
```
117+
118+
**Response**
119+
120+
```http
121+
HTTP/1.1 200 OK
122+
Cache-Control: no-cache
123+
Allow: OPTIONS,GET,HEAD,POST
124+
Content-Type: application/json;charset=utf-8
125+
126+
{
127+
"d": {
128+
"results": [
129+
{
130+
"__metadata": {
131+
"uri": " [Organization URI]/xrmservices/2011/OrganizationData.svc/AccountSet(guid'7a4814f9-b0b8-ea11-a812-000d3a122b89')",
132+
"type": "Microsoft.Crm.Sdk.Data.Services.Account"
133+
},
134+
"OwnershipCode": {
135+
"__metadata": {
136+
"type": "Microsoft.Crm.Sdk.Data.Services.OptionSetValue"
137+
},
138+
"Value": 2
139+
},
140+
"PrimaryContactId": {
141+
"__metadata": {
142+
"type": "Microsoft.Crm.Sdk.Data.Services.EntityReference"
143+
},
144+
"Id": "dff27d1f-a61b-4bfe-a203-b2e5a36cda0e",
145+
"LogicalName": "contact",
146+
"Name": "Sam Smith",
147+
"RowVersion": null
148+
},
149+
"OpenDeals_Date": "/Date(1663715691000)/",
150+
"Telephone1": "555-1234",
151+
"NumberOfEmployees": 500,
152+
"Name": "Contoso, Ltd. (sample)",
153+
"AccountNumber": "1111",
154+
"DoNotPhone": false,
155+
"IndustryCode": {
156+
"__metadata": {
157+
"type": "Microsoft.Crm.Sdk.Data.Services.OptionSetValue"
158+
},
159+
"Value": 7
160+
}
161+
},
162+
{
163+
"__metadata": {
164+
"uri": " [Organization URI]/xrmservices/2011/OrganizationData.svc/AccountSet(guid'fed58509-4af3-ec11-bb3d-000d3a1a51c1')",
165+
"type": "Microsoft.Crm.Sdk.Data.Services.Account"
166+
},
167+
"OwnershipCode": {
168+
"__metadata": {
169+
"type": "Microsoft.Crm.Sdk.Data.Services.OptionSetValue"
170+
},
171+
"Value": null
172+
},
173+
"PrimaryContactId": {
174+
"__metadata": {
175+
"type": "Microsoft.Crm.Sdk.Data.Services.EntityReference"
176+
},
177+
"Id": "ffd58509-4af3-ec11-bb3d-000d3a1a51c1",
178+
"LogicalName": "contact",
179+
"Name": "Susie Curtis",
180+
"RowVersion": null
181+
},
182+
"OpenDeals_Date": "/Date(1663715691000)/",
183+
"Telephone1": null,
184+
"NumberOfEmployees": null,
185+
"Name": "Fourth Coffee",
186+
"AccountNumber": null,
187+
"DoNotPhone": false,
188+
"IndustryCode": {
189+
"__metadata": {
190+
"type": "Microsoft.Crm.Sdk.Data.Services.OptionSetValue"
191+
},
192+
"Value": null
193+
}
194+
}
195+
]
196+
}
197+
}
198+
```
199+
200+
#### [Web API](#tab/webapi)
201+
202+
**Request**
203+
204+
```http
205+
GET [Organization URI]/api/data/v9.2/accounts?$select=ownershipcode,_primarycontactid_value,opendeals_date,telephone1,numberofemployees,name,accountnumber,donotphone,industrycode&$filter=_primarycontactid_value ne null&$count=true HTTP/1.1
206+
Prefer: odata.include-annotations="*"
207+
Prefer: odata.maxpagesize=2
208+
Accept: application/json
209+
OData-MaxVersion: 4.0
210+
OData-Version: 4.0
211+
If-None-Match: null
212+
```
213+
214+
**Response**
215+
216+
```http
217+
HTTP/1.1 200 OK
218+
Content-Type: application/json; odata.metadata=minimal
219+
OData-Version: 4.0
220+
Preference-Applied: odata.include-annotations="*"
221+
Preference-Applied: odata.maxpagesize=2
222+
223+
{
224+
"@odata.context": " [Organization URI]/api/data/v9.2/$metadata#accounts(ownershipcode,_primarycontactid_value,opendeals_date,telephone1,numberofemployees,name,accountnumber,donotphone,industrycode)",
225+
"@odata.count": 37,
226+
"@Microsoft.Dynamics.CRM.totalrecordcount": 37,
227+
"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded": false,
228+
"@Microsoft.Dynamics.CRM.globalmetadataversion": "73916662",
229+
"value": [
230+
{
231+
"@odata.etag": "W/\"73692809\"",
232+
"[email protected]": "Private",
233+
"ownershipcode": 2,
234+
"_primarycontactid_value@OData.Community.Display.V1.FormattedValue": "Sam Smith",
235+
"_primarycontactid_value@Microsoft.Dynamics.CRM.associatednavigationproperty": "primarycontactid",
236+
"[email protected]": "contact",
237+
"_primarycontactid_value": "dff27d1f-a61b-4bfe-a203-b2e5a36cda0e",
238+
"[email protected]": "9/20/2022 4:14 PM",
239+
"opendeals_date": "2022-09-20T23:14:51Z",
240+
"telephone1": "555-1234",
241+
242+
"numberofemployees": 500,
243+
"name": "Contoso, Ltd. (sample)",
244+
"accountnumber": "1111",
245+
"[email protected]": "Allow",
246+
"donotphone": false,
247+
"[email protected]": "Consulting",
248+
"industrycode": 7,
249+
"accountid": "7a4814f9-b0b8-ea11-a812-000d3a122b89"
250+
},
251+
{
252+
"@odata.etag": "W/\"68958376\"",
253+
"ownershipcode": null,
254+
"_primarycontactid_value@OData.Community.Display.V1.FormattedValue": "Susie Curtis",
255+
"_primarycontactid_value@Microsoft.Dynamics.CRM.associatednavigationproperty": "primarycontactid",
256+
"[email protected]": "contact",
257+
"_primarycontactid_value": "ffd58509-4af3-ec11-bb3d-000d3a1a51c1",
258+
"[email protected]": "9/20/2022 4:14 PM",
259+
"opendeals_date": "2022-09-20T23:14:51Z",
260+
"telephone1": null,
261+
"numberofemployees": null,
262+
"name": "Fourth Coffee",
263+
"accountnumber": null,
264+
"[email protected]": "Allow",
265+
"donotphone": false,
266+
"industrycode": null,
267+
"accountid": "fed58509-4af3-ec11-bb3d-000d3a1a51c1"
268+
}
269+
],
270+
"@odata.nextLink": " [Organization URI]/api/data/v9.2/accounts?$select=ownershipcode,_primarycontactid_value,opendeals_date,telephone1,numberofemployees,name,accountnumber,donotphone,industrycode&$filter=_primarycontactid_value%20ne%20null&$count=true&$skiptoken=%3Ccookie%20pagenumber=%222%22%20pagingcookie=%22%253ccookie%2520page%253d%25221%2522%253e%253caccountid%2520last%253d%2522%257bFED58509-4AF3-EC11-BB3D-000D3A1A51C1%257d%2522%2520first%253d%2522%257b7A4814F9-B0B8-EA11-A812-000D3A122B89%257d%2522%2520%252f%253e%253c%252fcookie%253e%22%20istracking=%22False%22%20/%3E"
271+
}
272+
273+
274+
```
275+
276+
---
277+
278+
105279
### Create records
106280

107281
These examples show the differences between the Organization Data Service and the Web API when creating records.
@@ -164,13 +338,62 @@ REQ_ID: a0c614be-50be-4c1e-9413-1c7ba459c5c9
164338
**Request**
165339

166340
```http
341+
POST [Organization URI]/api/data/v9.2/accounts?$select=ownershipcode,_primarycontactid_value,opendeals_date,customersizecode,telephone1,numberofemployees,name,accountnumber,donotphone,industrycode HTTP/1.1
342+
Prefer: odata.include-annotations="*"
343+
Prefer: return=representation
344+
OData-MaxVersion: 4.0
345+
OData-Version: 4.0
346+
If-None-Match: null
347+
Accept: application/json
348+
Content-Type: application/json
167349
350+
{
351+
"ownershipcode": 2,
352+
"[email protected]":"/contacts(dff27d1f-a61b-4bfe-a203-b2e5a36cda0e)",
353+
"opendeals_date": "2022-09-21T00:00:00Z",
354+
"customersizecode": 1,
355+
"telephone1":"555-1234",
356+
"numberofemployees": 500,
357+
"name":"Contoso, Ltd. (sample)",
358+
"accountnumber": "12227",
359+
"donotphone": true,
360+
"industrycode": 7
361+
}
168362
```
169363

170364
**Response**
171365

172366
```http
367+
HTTP/1.1 201 Created
368+
Content-Type: application/json; odata.metadata=minimal
369+
Preference-Applied: return=representation
370+
OData-Version: 4.0
371+
Preference-Applied: odata.include-annotations="*"
173372
373+
{
374+
"@odata.context": " [Organization URI]/api/data/v9.2/$metadata#accounts(ownershipcode,_primarycontactid_value,opendeals_date,customersizecode,telephone1,numberofemployees,name,accountnumber,donotphone,industrycode)/$entity",
375+
"@odata.etag": "W/\"73921446\"",
376+
"[email protected]": "Private",
377+
"ownershipcode": 2,
378+
"_primarycontactid_value@OData.Community.Display.V1.FormattedValue": "Sam Smith",
379+
"_primarycontactid_value@Microsoft.Dynamics.CRM.associatednavigationproperty": "primarycontactid",
380+
"[email protected]": "contact",
381+
"_primarycontactid_value": "dff27d1f-a61b-4bfe-a203-b2e5a36cda0e",
382+
"[email protected]": "9/20/2022 5:52 PM",
383+
"opendeals_date": "2022-09-21T00:52:24Z",
384+
"[email protected]": "Default Value",
385+
"customersizecode": 1,
386+
"telephone1": "555-1234",
387+
388+
"numberofemployees": 500,
389+
"name": "Contoso, Ltd. (sample)",
390+
"accountnumber": "12227",
391+
"[email protected]": "Do Not Allow",
392+
"donotphone": true,
393+
"[email protected]": "Consulting",
394+
"industrycode": 7,
395+
"accountid": "b68d56a6-4739-ed11-9db0-002248296d7e"
396+
}
174397
175398
```
176399

0 commit comments

Comments
 (0)