-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdataverse_formatted_values.cs
More file actions
27 lines (23 loc) · 1.11 KB
/
dataverse_formatted_values.cs
File metadata and controls
27 lines (23 loc) · 1.11 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
27
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
public class DataverseFormattedValuesExample
{
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,revenue,createdon";
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");
client.DefaultRequestHeaders.Add("Prefer", "odata.include-annotations=\"OData.Community.Display.V1.FormattedValue\"");
var response = await client.GetAsync(requestUrl);
response.EnsureSuccessStatusCode();
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}