Я пытаюсь создать объявление, но каждый раз оно выдает ошибку в этой строке:
var response = await _client.PostAsync(new Uri($"{_baseAddress}/Create"),
new StringContent(jsonModel, Encoding.UTF8, "application/json")).ConfigureAwait(false);
Я добавил точку останова, и он перестает создавать ответ. Ниже приводится моя функция, которую я использую
var advertApiModel = _mapper.Map<AdvertModel>(model);
var jsonModel = JsonConvert.SerializeObject(advertApiModel);
var response = await _client.PostAsync(new Uri($"{_baseAddress}/Create"),
new StringContent(jsonModel, Encoding.UTF8, "application/json")).ConfigureAwait(false);
var createAdvertResponse = await response.Content.ReadAsAsync<CreateAdvertResponse>().ConfigureAwait(false);
var advertResponse = _mapper.Map<AdvertResponse>(createAdvertResponse);
return advertResponse;
Ошибка, которую выводит терминал:
info: System.Net.Http.HttpClient.IAdvertApiClient.LogicalHandler[100]
Start processing HTTP request POST http://localhost:5000/adverts/v1/Create
System.Net.Http.HttpClient.IAdvertApiClient.LogicalHandler: Information: Start processing HTTP request POST http://localhost:5000/adverts/v1/Create
info: System.Net.Http.HttpClient.IAdvertApiClient.ClientHandler[100]
Sending HTTP request POST http://localhost:5000/adverts/v1/Create
System.Net.Http.HttpClient.IAdvertApiClient.ClientHandler: Information: Sending HTTP request POST http://localhost:5000/adverts/v1/Create
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 POST http://localhost:5000/adverts/v1/Create application/json; charset=utf-8 76
Microsoft.AspNetCore.Hosting.Diagnostics: Information: Request starting HTTP/1.1 POST http://localhost:5000/adverts/v1/Create application/json; charset=utf-8 76
Microsoft.AspNetCore.Hosting.Diagnostics: Information: Request finished in 5.2898000000000005ms 404
Когда я наведу курсор мыши на ответ var после того, как он его пропустит, он показывает эту ошибку:
{StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
Date: Fri, 17 Jan 2020 13:30:02 GMT
Server: Kestrel
Content-Length: 0
}}