Hello all.
I know I have this backwords. Usually the UI client calls the API with an httpclientfactory.
Well I have that working yes. Now I have a separate websocket on my API and when I get data I want my API to call my client UI with that data. So far I have it working my API can call my UI BUT my data model is null every time.
I have this in a
[Route("api/[controller]")]
I use the same code I would normally do with UI to API and I even copied my viewmodel over so the properties are 100% the same. I tried with jsonproperty and not.
Every time I do this I get a null model on my UI.
Here is what I have and what I am doing.
API Method to call Client UI
[HttpPost("SendUITradeStatus")]
public async Task<IActionResult> SendUITradeStatus(BinanceStreamOrderUpdate orderUpdate)
{
if (orderUpdate != null)
{
TestVM test = new TestVM
{
Symbol = orderUpdate.Symbol,
Price = orderUpdate.Price,
Quantity = orderUpdate.Quantity,
TradeID = orderUpdate.OrderId,
Status = orderUpdate.Status.ToString()
};
//var trade = JsonSerializer.Serialize(orderUpdate);
var trade = JsonSerializer.Serialize(test);
using var client = _httpClient.CreateClient("TraderUI");
using (var response = await client.PostAsync("/home/GetTradeStatus/",
new StringContent(trade, Encoding.UTF8, "application/json")))
{
if (response.IsSuccessStatusCode)
{
_logger.LogInformation("Success");
}
}
}
return Ok();
}
// UI Taking the API call and Accepting the Model
[HttpPost]
public IActionResult GetTradeStatus(TestVM trade)
{
return NoContent();
}