
Hello All,
I am try to access the Entity records using the Web api and Datatables,Using noraml web api ,DataTables.js and ADAL.js ,Please find the following code,its throwing following error 500,
var fetchxml = "<fetch mapping='logical' page='2' count='10' returntotalrecordcount='true' pagingcookie='%253ccookie%2520page%253d%25221%2522%253e%253caccountid%2520last%253d%2522%257bB8A19CDD-88DF-E311-B8E5-6C3BE5A8B200%257d%2522%2520first%253d%2522%257b475B158C-541C-E511-80D3-3863BB347BA8%257d%2522%2520%252f%253e%253c%252fcookie%253e'>" +
" <entity name='account' >" +
" <attribute name='address1_city' />" +
" <attribute name='name' />" +
" </entity>" +
"</fetch>";
$("#example").DataTable({
"processing": true,
"serverSide": true,
"aoColumnDefs": [
{ bSortable: true, aTargets: [0] },
{ bSortable: false, aTargets: ['_all'] }
],
"ajax":
{
url: encodeURI(organizationURI + "/api/data/v9.0/accounts?fetchXml=" + fetchxml),
dataType: 'application/json',
method: 'GET',
'beforeSend': function (request) {
request.setRequestHeader("Authorization", "Bearer " + token);
},
data: function (d) {
return d;
},
},
columns: [
{ title: "Name" },
{ title: "City" },
]
});
One more question,passing of bearer in Datables.
Thank,
*This post is locked for comments
I have the same question (0)Hi Sairam,
Basically this error means you cannot set any other option when using fetchxml. It seems along with fetchxml, you are also passing using something else. You can use fiddler or developer tool (network) to see the request which is building and identify what is it adding. You can also use Postman to confirm you implementation before actualy trying it oin code.
docs.microsoft.com/.../use-postman-web-api
Hope this helps.