4

When I Get the document list from SharePoint site I get this error "401 (Unauthorized)" only in Google Chrome, but in IE it works. This is my code

function GetListItems() {
var siteURL = "http://localhost:8032/_api/web/GetFolderByServerRelativeUrl('Data%20Do')/File";
            return $.ajax({
                url: siteURL,
                async: false,
                method: "GET",

                headers: {
                    "Accept": "application/json;odata=verbose",
                }
            });
        }

I get this two error in Google Chrome:

OPTIONS "http:......" 401 (Unauthorized)

and

jquery-1.7.2.min.js:4 XMLHttpRequest cannot load http://localhost:8032/_api/web/GetFolderByServerRelativeUrl('Data%20Do')/Files. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8032' is therefore not allowed access. The response had HTTP status code 401.

3
  • Close chrome and restart with the --disable-web-security Mode and then try if it opens up correctly Commented Feb 24, 2017 at 7:26
  • Question: Have you tried it in an incognito Chrome window? I have several sites that don't work in regular Chrome windows but work in incognito windows. Commented Feb 24, 2017 at 13:26
  • Localhost? What type of app are you developing? If this is a provider-hosted app, you need to use OAUTH, cookies or an NTLM header. If this is sharepoint-hosted, then you need the request digest.
    – wjervis
    Commented Feb 24, 2017 at 16:37

1 Answer 1

0

Turn on the Negotiate provider in Authentication in IIS.

After adding Negotiate, make an IIS reset . This will work .

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.