Skip to content

Instantly share code, notes, and snippets.

@fernandolopes
Created April 20, 2018 11:18
Show Gist options
  • Save fernandolopes/a90cf503d047929570ce1f59e63b9db0 to your computer and use it in GitHub Desktop.
Save fernandolopes/a90cf503d047929570ce1f59e63b9db0 to your computer and use it in GitHub Desktop.
using (var client = new HttpClient(HttpClientHandler))
{
client.DefaultRequestHeaders.Add("clientId", ClientId);
client.DefaultRequestHeaders.Add("accessToken", AccessToken);
client.BaseAddress = UriBase;
HttpRequestMessage request = new HttpRequestMessage(
HttpMethod.Delete,
$"holmes/api/document/{Id}"
);
request.Headers.Clear();
request.Headers.TryAddWithoutValidation("Content-Type", "application/x-www-form-urlencoded");
var resp = await client.SendAsync(request);
if (resp.IsSuccessStatusCode)
{
var conteudo = await resp.Content?.ReadAsStringAsync();
}
else
{
var conteudo = await resp.Content?.ReadAsStringAsync();
Console.WriteLine(conteudo);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment