madaxe2020
Well-known member
- Joined
- Sep 7, 2020
- Messages
- 50
- Programming Experience
- 5-10
I cant get my DeleteAsync working it silently fails at the highlited line 20 during the DeleteAsyn my controller is expecting the Json body below
Can anybody help?
Thanks
Madaxe
Can anybody help?
Thanks
Madaxe
json Body:
{
"continent_name": "Test"
}
Delete Async:
public static bool DeleteContinentData(string ContinentName)
{
bool ReturnBoolean = false;
Task<bool> ApplicationTask = ContinentDatabase.DeleteContinent(ContinentName);
ApplicationTask.Wait();
return ReturnBoolean;
}
private static async Task<bool> DeleteContinent(string ContinentName)
{
bool ReturnBoolean = false;
try
{
using (HttpClient httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Add("Accept", "application/json;charset=UTF-8");
httpClient.DefaultRequestHeaders.Add("x-api-key", ContinentDatabase._APIKey);
using (var content = new StringContent(JsonConvert.SerializeObject(new Dictionary<string, object>(){{ "continent_name", ContinentName } }), System.Text.Encoding.UTF8, "application/json"))
{
using (HttpResponseMessage HttpResponseMessage = await httpClient.DeleteAsync(ContinentDatabase._Url).ConfigureAwait(false))
{
if (HttpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK)
{
return true;
}
}
}
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
return ReturnBoolean;
}