c# connection

Hi to all,
i want to make an application witch connect, read and post data to the checkfront.
i have make an account,
First as i read i must authenticate
Is anywhere examples for c# ?


  • edited October 2014
    Generally, if you're familiar with your HTTP library, the documentation should provide most of what's needed to authenticate a connection. If you're using OAuth2 to authenticate and are not familiar with how it works, I would recommend using an existing library to ease the process. For OA2 auth, we use what's known as an "authorization code grant", which is effectively asking the user to log in to return a code that can be authorized and given a token in response.

    If however you are developing a server-to-server application such as a booking page, you can use token authentication, which can easily be sent as HTTP BASIC username:password credentials: http://api.checkfront.com/overview/auth.html#authenticating-with-token-pairs

    Admittedly it has been a long time since I've used the .NET HttpClient, so this may not work directly, and it's possible an easy to use library exists, but in a general sense your request process might look something like this (emphasis on the http.DefaultRequestHeaders.Authorization line):
    using System.Net.Http.Headers;
    using (var http = new HttpClient()) {

    http.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

    http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.UTF8.GetBytes("API-KEY:API-SECRET")));

    http.BaseAddress = new Uri("https://my-company.checkfront.com/api/3.0/");

    HttpResponseMessage response = await http.GetAsync("booking/index");
    if (response.IsSuccessStatusCode) {
    JsonArray content = await response.Content.ReadAsAsync<JsonArray>();
    Keep in mind in this example that API-KEY and API-SECRET should be the exact values corresponding to your token setup page, and my-company.checkfront.com would be replaced with your company address. "booking/index" would be whatever API endpoint you're trying to reach, in this case the list of bookings that have been made in the account. In most cases you will want to include additional arguments, and look into documentation for a POST request as well if you're not familiar with it already.
This discussion has been closed.