On my site I make a post request using a ajax call to an azure function url like so:
var name = $("input#name").val();
var number = $(input#number").val();
$.ajax({
url: "azurefunctionurl.com",
type: "POST",
data: {
name: name,
number: number,
},
cache: false,
success: function() {
...stuff here....
},
error: function () {
...stuff here...
},
});
One or more errors occurred. ---> Error parsing boolean value. Path '', line 1, position 1.
#r "Newtonsoft.Json"
using System;
using System.Net;
using Newtonsoft.Json;
public static async Task<object> Run(HttpRequestMessage req, TraceWriter log)
{
log.Verbose($"Webhook was triggered!");
string jsonContent = await req.Content.ReadAsStringAsync();
dynamic data = JsonConvert.DeserializeObject(jsonContent);
string name = data.name;
string number = data.number;
log.Verbose(name);
}
because when you post by ajax with default content type, the form data will be
name=xxxx&number=yyyy
so whether you need to change your azure function codes to recognize the name value pair, or you need to set ajax post content type to
application/json