Re: Sample code to integrate with .NET #important #api

Christopher Warrington

On 2020-04-08 at 9:02:55 AM, Nadeem Shehzad <> wrote:

Does anyone have a sample .NET code to call basic API endpoints such as
authentication, creating group etc.
I've just uploaded a simple app that sets a user's location using the API
from C# at

.NET's HttpClient will automatically handle the auth cookies that
uses, so it's pretty simple to use the API. Typically you just POST to the
right URI with null for the content.

QueryHelpers.AddQueryString from the Microsoft.AspNetCore.WebUtilities is
helpful to build these URIs.

I've been able to use System.Text.Json to parse the responses that I've
needed so far. I had to write a little snake_case naming policy to convert
between C#'s prevailing UpperCamelCase style and the lower_snake_case used

Here's an example that calls login:

var parameters = new Dictionary<string, string>()
["email"] = email,
["password"] = password,
// 2FA is shown in the full example, linked above

string loginUri = QueryHelpers.AddQueryString(

HttpResponseMessage response = await _httpClient.PostAsync(
content: null);


Christopher W. <>

Join to automatically receive all group messages.