using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
// Define the base URL of the REST API
string baseUrl = "https://a...content-available-to-author-only...s.com/developer/api/";
// Define the bearer token
string bearerToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTAyMzQwNjIsImV4cCI6MjAyNTU5NDA2MiwidG9rZW5fdHlwZSI6ImRldmVsb3Blcl9hY2Nlc3MiLCJmaXJzdF9uYW1lIjoiVmlzaGFsIiwibGFzdF9uYW1lIjoiU2F4ZW5hIiwib2NjdXBhdGlvbiI6Ik90aGVyIiwidXNlcl9jb21wYW55IjoiQXRraW5zIiwidXNlcl9lbWFpbCI6InZpc2hhbC5zYXhlbmFAYXRraW5zZ2xvYmFsLmNvbSJ9.C-C0xrce2yQj4SHB083wtYElvNQj9b_Q5nvGhtXbTwI";
// Create an instance of HttpClient
using (HttpClient client = new HttpClient())
{
// Set the base address of the API
client.BaseAddress = new Uri(baseUrl);
// Add bearer token to the request headers
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bearerToken);
try
{
// Send a GET request to the API endpoint
HttpResponseMessage response = await client.GetAsync("getapitoken/");
// Check if the request was successful
if (response.IsSuccessStatusCode)
{
// Read the response content as a string
string responseData = await response.Content.ReadAsStringAsync();
// Print the response data
Console.WriteLine(responseData);
}
else
{
// Print error message if request was not successful
Console.WriteLine($"Failed to retrieve data. Status code: {response.StatusCode}");
}
}
catch (HttpRequestException e)
{
// Print any exceptions that occur during the request
Console.WriteLine($"Request failed: {e.Message}");
}
}
}
}