Hello,
We are unable to call some of the REST api's via Kendo framework , which we had successfully called via Jquery ajax requests.
Here below given are the
1. C# Code example of the REST API.
2. Code example which can successfully call the REST API
via jquery ajax request.
3. Format which we have used to call the REST API
from kendo framework.
It would appreciated if you can provide us with the correct Kendo code format to call this REST api.
1. C# Code example of the REST API.
2. Code example which can successfully call the REST API
via jquery ajax request.
3. Format which we have used to call the REST API
from kendo framework.
Kindly provide us with correct code to call the API.
Thanks in advance
We are unable to call some of the REST api's via Kendo framework , which we had successfully called via Jquery ajax requests.
Here below given are the
1. C# Code example of the REST API.
2. Code example which can successfully call the REST API
via jquery ajax request.
3. Format which we have used to call the REST API
from kendo framework.
It would appreciated if you can provide us with the correct Kendo code format to call this REST api.
1. C# Code example of the REST API.
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
//[AuthenticatingHeader]
public
partial
class
Account
{
[WebInvoke(Method =
"POST"
, UriTemplate =
"DeleteAccount?uniqueaccessid={uniqueaccessid}"
, BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat =
WebMessageFormat.Json)]
public
static
void
DeleteAccount(
string
uniqueaccessid,
string
accountId)
{
int
userid = Accessibility.GetUserId();
if
(userid > 0)
{
string
output = Tools.ServiceLayer.Account.DeleteAccount(Convert.ToInt32(accountId), Convert.ToInt32(userid)).ToString();
HttpContext.Current.Response.ContentType =
"application/json; charset=utf-8"
;
HttpContext.Current.Response.Write(output);
}
}
}
2. Code example which can successfully call the REST API
via jquery ajax request.
function
GetTransactionAccount(uniqueaccessid, accountId) {
var
jData = {};
jData.uniqueaccessid = uniqueaccessid;
jData.accountId = accountId;
$.ajax({
url: RestBaseURL +
"Account/"
DeleteAccount?uniqueaccessid=
" + uniqueaccessid + "
",
data: JSON.stringify(jData),
dataType:
"json"
,
type:
"POST"
,
async:
false
,
contentType:
"application/json; charset=utf-8"
,
cache:
false
,
success:
function
(response) {
alert(response);
},
failure:
function
() { alert(
"failed"
); }
});
}
3. Format which we have used to call the REST API
from kendo framework.
var
changeaccid;
function
GetAccountInfo(uniqueaccessid) {
var
accid;
var
dataSourceobj =
new
kendo.data.DataSource({
transport: {
read:{
url:RestBaseURL +
"Cash/GetAccountInfo?uniqueaccessid="
+ uniqueaccessid +
""
,
dataType:
"json"
,
type:
"POST"
},
destroy:{
url: RestBaseURL +
"Account/DeleteAccount?uniqueaccessid="
+ uniqueaccessid ,
//url: RestBaseURL + "Account/DeleteAccount",
dataType:
"json"
,
type:
"POST"
},
parameterMap:
function
(options, type) {
if
(type ==
"destroy"
) {
return
{
'uniqueaccessid'
: uniqueaccessid,
'accountId'
: options.models[0].id
};
}
}
},
batch:
true
,
pageSize: 10,
schema: {
type:
"json"
,
model: {
fields: {
id : {type:
"number"
},
lender: { type:
"string"
},
id: { type:
"string"
},
rate: { type:
"number"
},
startingbalance: { type:
"number"
},
emergencyfund: { type:
"number"
},
startingdate: { type:
"date"
},
balance: { type:
"number"
}
}
}
}
});
$(
"#grid2"
).kendoGrid({
dataSource: dataSourceobj,
height: 130,
selectable:
"multiple"
,
change:
function
() {
changeaccid =
this
.dataItem(
this
.select()).id;
},
sortable:
true
,
resizable:
true
,
reorderable:
true
,
filterable:
true
,
columnMenu:
true
,
pageable:
true
,
columns: [
{ title:
""
,template: "<img src=
'images/ico/acc_on.png'
title='Green: Consider
for
Debt eliminator payoff. Red: Not consider
for
Debt eliminator payoff'/>
",width: "
25px"},
{ title:
"Id"
,field:
"id"
,width:
"30px"
},
{ title:
"Bank Name"
,field:
"lender"
,width:
"185px"
},
{ title:
"A/C Number"
,field :
"accountnumber"
,width:
"90px"
},
{ title:
"Interest Rate%"
,field:
"rate"
,format:
"{0:N}"
,width:
"110px"
},
{ title:
"Beg. Balance"
,field:
"startingbalance"
, format:
"{0:c}"
,width:
"95px"
},
{ title:
"Emerg. Fund"
,field:
"emergencyfund"
, format:
"{0:c}"
,width:
"95px"
},
{ title:
"Opening Date"
,field:
"startingdate"
,template:
'#= kendo.toString(startingdate,"MM/dd/yyyy") #'
,width:
"100px"
},
{ title:
"Balance"
, field:
"balance"
, format:
"{0:c}"
,width:
"70px"
},
//{ title:"Action", template: "<img src='images/ico/edit.png' title='Edit'/><img src='images/ico/delete.png'
title=
'Delete'
/>
",width: "
50px"}],
{title:
"Action"
, command: [
"edit"
,
"destroy"
], width:
"130px"
}],
editable:
"inline"
});
}
Kindly provide us with correct code to call the API.
Thanks in advance