H All ,
Getting below error while sending request to azure function from a web app . all hosted local Visual studio 2022
mscorlib: Exception while executing function: FuncToQ. Microsoft.Azure.WebJobs.Host: Exception binding parameter ‘req’. Newtonsoft.Json: Could not create an instance of type Microsoft.AspNetCore.Http.HttpRequest. Type is an interface or abstract class and cannot be instantiated. Path ‘Id’, line 1, position 6.
Below is the function signature :
public static async Task Run([HttpTrigger(AuthorizationLevel.Function, “get”, “post”, Route = null)] HttpRequest req,
[Queue(“SalesRequestInbound”, Connection = “AzureWebJobsStorage”)] IAsyncCollector SalesRequestQueue,
TraceWriter log)
Trying to send request to Azure Function from Web app controller :
salesRequest.Id = “123”;
using (var content = new StringContent(JsonConvert.SerializeObject(salesRequest), System.Text.Encoding.UTF8, “Application/json”))
{
HttpResponseMessage response = await client.PostAsync(“http://localhost:7071/api/FuncToQ”, content);
var returnval= response.Content.ReadAsStringAsync().Result;
}
return RedirectToAction(nameof(Index));
trying to receive request in azure function from simple a web application . Function is used to wrie message into azure queue.