
Examples
In order to make use of the API's, you will require a subscription key. This key provides the user access to certain products on the API as well access to relevant helpful API information on the Developer Portal. This subscription key should be kept a secret as it provides security for the data.
Async
C# Code Sample:
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
using System.IO;
namespace CSHttpClientSample
{
static class Program
{
static void Main()
{
MakeRequest();
Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}
static async void MakeRequest()
{
var client = new HttpClient();
// Request headers
client.DefaultRequestHeaders.CacheControl = CacheControlHeaderValue.Parse("no-cache");
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "66ae606f3a6b41d88d8b742cb9fbfe10");
var uri = "https://apim-ais-penbev-dev.azure-api.net/masterdata/customerasync";
HttpResponseMessage response;
// Request body
using (var content = new StringContent(""))
{
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
response = await client.PostAsync(uri, content);
}
}
}
}
Sync
C# Code Sample:
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://apim-ais-penbev-dev.azure-api.net/lookups/assetmodelcodesync");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Ocp-Apim-Subscription-Key", "b3077ef9c6914499afcfb85ec8096e05");
var content = new StringContent("{\n \"StartDate\": \"2023/06/01\",\n \"EndDate\": \"\",\n \"PageSize\": \"10\"\n}\n", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());