I was asked to develop a program that extracts the properties of each user profile. I'm using ASP.NET Core and Visual Studio and I'm trying to use AJAX and Javascript to do the requests. Here's my code.

        var url = "https://[...]";

        $(document).ready(function () {

            $("button").click(function () {
                    url: url + "/_api/web/lists",
                    crossDomain: true,
                    dataType: "jsonp",
                    method: "GET",
                    headers: {
                        "Accept": "application/jsonp; odata=verbose",
                        "X-RequestDigest": $("#__REQUESTDIGEST").val(),

                    success: function () {
                    error: function (xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response



<div class="text-center">
    <h1 class="display-4">Welcome</h1>
    <p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
    <button class="btn">Click</button>

However, like this, I can't access the API, as it returns a 403 error. How can I pass on my credentials so it recogninzes my login and what do I need to change here so I get a successful request?

Also, do I need to pass the script to a Sharepoint Add-in for this to work?

Thank you in advance

  • Is this definitely a cross-domain request? According to this answer, apparently SharePoint does not support JSONP/CORS. If it is just a request to a different site/site collection/web app/server/etc, but is within the same domain, I do have some suggestions. Apr 15, 2020 at 19:32

1 Answer 1


SharePoint Rest API has not exposed such an endpoint to enumerate all users. '_api/web/siteusers' only list all users related to this site.

Below is a workaround about how to search all users in Local People Result:

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.