javascript - Trying to Post data to my Rest API -


i have rest api , need poost base 64 data javascript.

this code-behind:

[httppost] [route("services/image/upload")] public void upload(string imagedata) {     stuff }   var url = "http://informedworker.co.uk/api/services/image/upload?" +"imagedata=" +  base64;  $(document).ready(function () {     $.post(url)         .done(function (url) {             // on success, 'data' contains list of products.             $("#error").html("done");         })      .fail(function (jqxhr, textstatus, err) {          $('#error').html('error: ' + err);      }); }); 

but error 'not found'.

is way passing parameters?

you're post excpects link "services/image/upload?imagedata=", you're link looks "services/image/upload?base64=imagedata="

you need pass base64 value object called imagedata

$(document).ready(function () { var imagedata = base64; $.post(url, imagedata)     .done(function (url) {         // on success, 'data' contains list of products.         $("#error").html("done");     })  .fail(function (jqxhr, textstatus, err) {      $('#error').html('error: ' + err);  }); }); 

or write the called url like

$(document).ready(function () { $.post(url + "?imagedata=" + base64)     .done(function (url) {         // on success, 'data' contains list of products.         $("#error").html("done");     })  .fail(function (jqxhr, textstatus, err) {      $('#error').html('error: ' + err);  }); }); 

Comments