I have a kendo mobile app with a view that is binded to an observable object
What i want basically is to just make a simple POST call using kendo datasource passing this viewmodel to webapi post method
But I cant figure out how, I tried this code but it doesnt work
can anyone point me to the right direction on how to make this kind of call?
//Post Account View Model
var
postaccountModel = kendo.observable({
Username:
null
,
Password1:
null
,
Password2:
null
,
Firstname:
null
,
Middlename:
null
,
Lastname:
null
,
Gender:
null
,
BirthDate:
null
});
What i want basically is to just make a simple POST call using kendo datasource passing this viewmodel to webapi post method
public
class
PostAccountModel
{
public
string
Username {
get
;
set
; }
public
string
Password1 {
get
;
set
; }
public
string
Password2 {
get
;
set
; }
public
string
Firstname {
get
;
set
; }
public
string
Middlename {
get
;
set
; }
public
string
Lastname {
get
;
set
; }
public
string
Gender {
get
;
set
; }
public
DateTime? BirthDate {
get
;
set
; }
}
[Authorize(Roles = Service.Security.Role.Guest)]
public
void
Post(PostAccountModel value)
{
}
But I cant figure out how, I tried this code but it doesnt work
$(
"#button-save"
).on(
"click"
,
function
() {
if
(createaccountvalidator.validate()) {
var
authheader = EMRGUEST;
var
authbase64 = Base64.encode(authheader);
var
dataSource =
new
kendo.data.DataSource({
transport: {
create: {
url: EMRAPIURL +
"account"
,
dataType:
"jsonp"
,
type:
"POST"
,
beforeSend:
function
(xhr) {
xhr.setRequestHeader(
'Authorization'
,
'Basic '
+ authbase64);
},
data: kendo.stringify(postaccountModel)
}
}
});
dataSource.sync();}
});
can anyone point me to the right direction on how to make this kind of call?