I have this code:
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);
When I run this and trace it, it keeps getting the error Invalid expression term 'string' at var response and the terminal displays:
info: System.Net.Http.HttpClient.IAdvertApiClient.ClientHandler[101] Received HTTP response after 246.85940000000002ms - InternalServerError System.Net.Http.HttpClient.IAdvertApiClient.ClientHandler: Information: Received HTTP response after 246.85940000000002ms - InternalServerError
new StringContentand usejsonModelvariable instead. - LinkedListT