415 when deleting contact list

SOLVED
Go to solution
JoseC212
Occasional Participant

415 when deleting contact list

Hi, 

 

Call to Delete contact_lists returns

status code 415

response 

[
{
"error_key": "contacts.api.error",
"error_message": "The provided content-type 'text\/plain' is not supported."
}]

 

Why is content type needed as the call is not providing any request content.  

 

Snippet of API client ASP.Net Core 3.1

httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {accessToken}");
httpClient.DefaultRequestHeaders.Add("Accept", "application/json");

 

var response = await httpClient.DeleteAsync($"{baseUrl}{apiVersion}/contact_lists/{contactListId}");
var content = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
var jObject = JObject.Parse(content);
return mapper.Map<DeleteContactListDto>(jObject);
}
else
logger.Warning(content);

Thanks

1 ACCEPTED SOLUTION
JoseC212
Occasional Participant

Changed how the request is sent and added empty content

 

 var request = new HttpRequestMessage(HttpMethod.Delete, $"{baseUrl}{apiVersion}/contact_lists/{contactListId}");
 request.Headers.Add("Authorization"$"Bearer {accessToken}");
 request.Headers.Add("Accept""application/json");
 request.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
 
and sent request using 
var response = await httpClient.SendAsync(request);

View solution in original post

1 REPLY 1
JoseC212
Occasional Participant

Changed how the request is sent and added empty content

 

 var request = new HttpRequestMessage(HttpMethod.Delete, $"{baseUrl}{apiVersion}/contact_lists/{contactListId}");
 request.Headers.Add("Authorization"$"Bearer {accessToken}");
 request.Headers.Add("Accept""application/json");
 request.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
 
and sent request using 
var response = await httpClient.SendAsync(request);

View solution in original post

Developer Portal

View API documentation, code samples, get your API key.

Visit Page