I’m having problem calling my API from “Blazor” app with Fluent UI(if that matter). When I start the app, on “OnInitializedAsync()” method I’m calling API what should get list of id’s, and after that I’m calling again my API again to get detailed information about specific id. The problem is that, when I call the second API with given id, id parameter is not sent down to the API. Any suggestions are welcome.
There are code snippets:
protected override async Task OnInitializedAsync()
{
FhirIgResponse res = await mappingService.GetBundles();
bundleOptions = res.Results;
selectedBundle = res.Results.First();
await OnBundleSelect();
}
private async Task OnBundleSelect()
{
try
{
if (!string.IsNullOrWhiteSpace(selectedBundle))
{
execScript = await mappingService.GetExecScript(selectedBundle);
}
else
{
toastService.ShowError("Please select a valid Id");
}
}
catch (Exception ex)
{
toastService.ShowError($"OnBundleSelect with parameter: {selectedBundle} and error: {ex.Message}.");
}
}
private async Task<T> SendRequestAsync<T>(string url, HttpMethod method, object? parameters = null)
{
if (string.IsNullOrWhiteSpace(url))
{
throw new ArgumentException($"Parameter ${nameof(url)} is required.");
}
using (HttpRequestMessage httpRequestMessage = new HttpRequestMessage(method, url))
{
if (method == HttpMethod.Post)
{
httpRequestMessage.Content = JsonContent.Create(parameters,
new MediaTypeHeaderValue("application/json"),
new JsonSerializerOptions() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull });
await httpRequestMessage.Content.LoadIntoBufferAsync();
}
HttpResponseMessage httpResponseMessage = await _HttpClient.SendAsync(httpRequestMessage);
if (httpResponseMessage.StatusCode != System.Net.HttpStatusCode.OK)
{
throw new Exception($"Error sending request the status code was: {httpResponseMessage.StatusCode}. The response message was: {await httpResponseMessage.Content.ReadAsStringAsync()}");
}
string content = await httpResponseMessage.Content.ReadAsStringAsync();
return Utilities.ParseContentToT<T>(content);
}
}
I tried change the RenderMode of the Blazor, but without any results.