On 2020-04-08 at 9:02:55 AM, Nadeem Shehzad <email@example.com> wrote:
Does anyone have a sample .NET code to call basic API endpoints such asI've just uploaded a simple app that sets a user's location using the API
from C# at https://github.com/chwarr/gio-api-example.
.NET's HttpClient will automatically handle the auth cookies that Groups.io
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(
Christopher W. <firstname.lastname@example.org>