JQuery Ajax POST method returning bad request
-
I’m currently having an issue on my following code, POST request is returning “Bad Request” error.
function UpdateOrderStatus(){
var domainName = "http://xxxxxx.xxxxxx.com/xxxx.xxxx.xxxxx/1_1/MainService.svc/webapi/UpdateOrderStatus"; var orderData = { "wsCodeCrypt" : "xxx", "caUid" : "xxx", "caPwd" : "xxx", "slsDoc" : "SO", "slsRef" : "00001", "status" : "pending" }; $.ajax({ url: domainName, method: "POST", data: orderData, cache: false, dataType: "xml", success: function(xml) { console.log(xml); }, error: function( xhr, status, errorThrown ) { console.log( "Error: " + errorThrown ); console.log( "Status: " + status ); } });
}
The code works if I use the full URL and ditch the entire “data: orderData” option. Anyone knows why this is the case?
-
@AspiringWizard At first glance if it works by passing the data on the URL I would say you’re looking into a GET request rather than a POST.