I have an ASP.NET Web API endpoint with controller action defined as follows :
[HttpPost]
public HttpResponseMessage Post([FromBody] object text)
Very late to this party with a grossly simplified solution. I had success with this code in the controller method:
public HttpResponseMessage FileHandler()
{
HttpResponseMessage response = new HttpResponseMessage();
using (var reader = new StreamReader(System.Web.HttpContext.Current.Request.GetBufferedInputStream()))
{
string plainText = reader.ReadToEnd();
} .....}
And on the client side, these are the Ajax options I used:
var ajaxOptions = {
url: 'api/fileupload/' + "?" + $.param({ "key": metaKey2, "File-Operation": "Remove", "removalFilePath": $removalFilePath, "Audit-Model": model, "Parent-Id": $parentId, "Audit-Id": $auditId }),
type: 'POST', processData: false, contentType: false, data: "BOB"
};