-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdataverse_filtering.cs
More file actions
26 lines (22 loc) · 1.02 KB
/
dataverse_filtering.cs
File metadata and controls
26 lines (22 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
public class DataverseFilteringExample
{
public static async Task Main()
{
var environmentUrl = "https://yourorg.crm.dynamics.com";
var accessToken = "YOUR_ACCESS_TOKEN";
var requestUrl = environmentUrl + "/api/data/v9.2/accounts?$select=name,telephone1&$filter=statecode eq 0 and contains(name,'Health')";
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("OData-Version", "4.0");
client.DefaultRequestHeaders.Add("OData-MaxVersion", "4.0");
var response = await client.GetAsync(requestUrl);
response.EnsureSuccessStatusCode();
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}