Obtener mis detalles
En esta sección vamos a solicitar los detalles más simples posibles desde la API de Legalesign para comprobar que todo está funcionando. Este ejemplo mostrará los resultados en la terminal.
Ejemplo desde la línea de comandos
Crea un archivo llamado CLIExample.cs en tu proyecto:
CLIExample.cs
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
namespace CLILegalesignExamples
{
class CLILegalQLExample
{
static async Task Main(string[] args)
{
Console.WriteLine("Legalesign C# Command Line Example");
var httpClient = new HttpClient();
string token = "<token-or-api-key>";
// Set up the GraphQL client
httpClient.BaseAddress = new Uri("https://graphql.uk.legalesign.com/graphql");
httpClient.DefaultRequestHeaders.Add("User-Agent", "LegalesignCLI");
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var queryObject = new
{
query = @"query {
user {
email
firstName
lastName
}
}",
variables = new { }
};
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
Content = new StringContent(JsonSerializer.Serialize(queryObject), Encoding.UTF8, "application/json")
};
using (var response = await httpClient.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var responseString = await response.Content.ReadAsStringAsync();
if (responseString != null)
{
Console.WriteLine(responseString);
}
}
Console.ReadLine();
}
}
}
Ejecutar el ejemplo
En VS Code, presiona Ctrl-F5 o F5. Deberías ver algo como:

Si recibes errores de autenticación, revisa Autenticarse con la API. Si ves:
{"data":{"user":{"email":"<your-email>","firstName":"Alex","lastName":"Why"}}}
¡Entonces tu consulta se ha completado con éxito! Podrás notar que no especificamos un userId — el objeto User asume que hablas de ti mismo sin necesidad de un ID. Si quieres probar otras consultas, revisa el Explorador GraphiQL.