Join the Ready, Set, Send Challenge Week 3. Share your QR code or landing page and win a badge!

415 when deleting contact list

SOLVED
Go to solution
JoseC212
Rookie
0 Votes

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
Rookie
0 Votes

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
Rookie
0 Votes

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);
Resources
Developer Portal

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

Visit Page

Announcements

API Updates

Join our list to be notified of new features and updates to our V3 API.

Sign Up