I have the following service:
[HttpGet]
[Route("save")]
public async Task<dynamic> save(VendaModel[] venda, string CnpjEstab)
{
dynamic retorno = null;
VendaModel ultima = new VendaModel();
//TODO
}
I'm trying to consume as follows:
public async static void SalvarArray(dynamic venda, string CnpjEstab)
{
string retorno;
try
{
var url = UrlBase.urlBase + "/GetVendas/save";
var a = new { venda, CnpjEstab };
var json = JsonConvert.SerializeObject(a);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
HttpClient req = new HttpClient();
HttpResponseMessage resp = await req.PostAsync(url, stringContent);
if (resp.StatusCode == HttpStatusCode.OK)
{
retorno = resp.Content.ReadAsStringAsync().GetAwaiter().GetResult();
}
}
catch (Exception err)
{
GeraLogError.GeraLog("GetVendas", MethodBase.GetCurrentMethod().Name, err.Message);
retorno = err.Message;
}
//return retorno;
}
But it's not working, the application is simply aborted (without any warning), does not fall into the Api debug, is there something wrong with the code?
I'm using C #