I am trying to get form data within an Azure function.
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
log.Info("C# HTTP trigger function processed a request.");
NameValueCollection col = req.Content.ReadAsFormDataAsync().Result;
return req.CreateResponse(HttpStatusCode.OK, "OK");
}
I am getting the following error:
Exception while executing function: System.Net.Http.Formatting: No MediaTypeFormatter is available to read an object of type 'FormDataCollection' from content with media type 'multipart/form-data'.
I am trying to parse inbound emails via SendGrid as described here. https://sendgrid.com/docs/Classroom/Basics/Inbound_Parse_Webhook/setting_up_the_inbound_parse_webhook.html
The incoming request looks correct.
--xYzZY Content-Disposition: form-data; name="attachments"
0 --xYzZY Content-Disposition: form-data; name="text"
Hello world --xYzZY Content-Disposition: form-data; name="subject"
Subject --xYzZY Content-Disposition: form-data; name="to"