I’m trying to send a post request using json as the request body. Here is my code:
var body = {
data1: formData1,
data2: formData2
};
$.ajax({
url: submitUrl,
type: "POST",
data: JSON.stringify(body),
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (resp) {
/* Function for success */
}
});
formData1 and formData2 are strings that were defined earlier in the application.
Everytime that I submit a request using this function, it reverts to the content-type being application/x-www-form-urlencoded and gives me an HTTP 415 error.