Reputation: 155
I'm trying to run one of my web app APIs but when prompted for user and password, it responded with 401 access denied. I've tried changing from NTLM to Kerberos. It still won't work. I'm new to SharePoint.
This is how I call my API :
var json = $.ajax({
url: (serviceType == "wcf" ? wcfServicesUrl : servicesApi) + wcfServiceUri,
type: type,
data: data,
crossDomain: true,
contentType: "application/json",
dataType: "json",
xhrFields: {
withCredentials: true
}
)};
Upvotes: 4
Views: 21716
Reputation: 53
Try below solution, it worked in my case. First open IIS and click your site. And then:
Upvotes: 0
Reputation: 1
i have recently came across production issue where my PRODUCTION API server suddenly starts giving 401 unauthorized error , I searched a lot on internet but fruitless than I took support from Microsoft as this application was running fine , suddenly the error occurred , Microsoft just took a look on which dot net frame work the application is using mine was 4.0 , so they advised to go to C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files
when an application is hosted on IIS , it compiles its dlls and other files once in this particular folder ,if it gets lock or corrupt the application will start giving 401 unauthorized error and delete the temp files and restarted IIS and Voala it start working . Please mark it as a answer if you are comfortable
Upvotes: 0
Reputation: 10410
You need to adjust the authentication settings in IIS for your Web API application.
Depending on what you are trying to do, you may need one or more of these options enabled.
Your app pool identity also plays a role. Make sure they user is properly authorized to access your content / data / etc.
Update: set Windows Authentication as Enabled, make sure all others are disabled. Do not use Kerberos. Add URL for your web app to Trusted Sites in your browser.
Upvotes: 0