Click here to Skip to main content
15,305,361 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to solve 401 (Unauthorized) exception while calling APi controller from Ajax call in data table in mvc

What I have tried:

function QAReport() {
           "processing": true,
           "serverSide": false,
           "destroy": true,
           "iDisplayLength": 50,
           "order": [0, 'desc'],
           "ajax": {
               "url": '@AppConstants.ApiUrl' + 'ProductivityDashboard/ProductivityDashboardApi/QAReport',
               "type": 'GET',
               "data": {},
               "dataType": 'json',
               "dataSrc": ''
           "columns": [
           { "data": "DeveloperName" },
           { "data": "ProjectName" },
           { "data": "Goal" },
           { "data": "UserStory" },
           { "data": "DeployedDateTime" },
           "language": {
               "emptyTable": "There are no data at present."
           "responsive": true
David_Wimbley 8-Aug-18 11:19am
The error is pretty clear, you are making a call to an API endpoint that has an [Authorize] attribute on it and you did not authenticate first. Either remove the authorize attribute (probably not smart but an option) or authenticate in some fashion to the API prior to calling it for data for your data table

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900