Although it might be late to answer this question but
I’ve faced a similar problem and the following code worked for me.
HttpRequestMessage request = new HttpRequestMessage
{
Content = new StringContent("[YOUR JSON GOES HERE]", Encoding.UTF8, "application/json"),
Method = HttpMethod.Delete,
RequestUri = new Uri("[YOUR URL GOES HERE]")
};
await httpClient.SendAsync(request);
UPDATE on .NET 5
.NET 5 introduced JsonContent. Here is an extension method using JsonContent:
public static async Task<HttpResponseMessage> DeleteAsJsonAsync<TValue>(this HttpClient httpClient, string requestUri, TValue value)
{
HttpRequestMessage request = new HttpRequestMessage
{
Content = JsonContent.Create(value),
Method = HttpMethod.Delete,
RequestUri = new Uri(requestUri, UriKind.Relative)
};
return await httpClient.SendAsync(request);
}