valid json request body in jquery json
var uid= "user";
var pwd= "user@123";
var doAuthenticate = function (uid, pwd) {
var token = user + ':' + password;
var hashCode = btoa(token);
return 'Basic ' + hashCode;
};
var createDate = new Date().getTime();
var requestBody = { user: { Id: 9, CreatedDate: '/Date(' + createDate + ')/'} };
var JSONrequestBody=JSON.stringify(requestBody);
$.ajax({
url: 'http://aspdotnetblogspot.blogspot.in/2013/06/authentication-on-wcf-rest-service-json.html',
type: 'POST',
data: JSONrequestBody,
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization", doAuthenticate(uid, pwd));
},
async: runInBackground,
contentType: 'application/json',
success: successHandler,
error: function (jqXHR, textStatus, errorThrown) {
$('#msgText').html(jqXHR.responseText);
}
});
Thanks you.
var uid= "user";
var pwd= "user@123";
var doAuthenticate = function (uid, pwd) {
var token = user + ':' + password;
var hashCode = btoa(token);
return 'Basic ' + hashCode;
};
var createDate = new Date().getTime();
var requestBody = { user: { Id: 9, CreatedDate: '/Date(' + createDate + ')/'} };
var JSONrequestBody=JSON.stringify(requestBody);
$.ajax({
url: 'http://aspdotnetblogspot.blogspot.in/2013/06/authentication-on-wcf-rest-service-json.html',
type: 'POST',
data: JSONrequestBody,
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization", doAuthenticate(uid, pwd));
},
async: runInBackground,
contentType: 'application/json',
success: successHandler,
error: function (jqXHR, textStatus, errorThrown) {
$('#msgText').html(jqXHR.responseText);
}
});
Thanks you.