Stop Ajax-Restful service from prompting login?

Sean Su 1 Reputation point
2020-09-23T22:24:41.14+00:00

How to stop Ajax-Restful service from prompting login?
It is an anonymous site, but Restful api requires people to log in. Is there way to stop it?

SP.SOD.executeFunc("sp.js", "SP.ClientContext", function() {
SP.SOD.executeFunc("sp.runtime.js", "SP.ClientContext", function() {
var context = SP.ClientContext.get_current();

var queryUrl= "/sites/publicaccess/sitename/_api/web/lists/getbytitle('EssentialVisitorList')/items?$Select=*,Editor/Title&$Expand=Editor/Title";
var qryStr = "&$filter=(ApptLocation eq '" + splitStr + "')";

  $.ajax({
    url: queryUrl,
    method: "GET",
    headers: {
      "Accept": "application/json; odata=verbose"
    },
    success: onQuerySuccess,
    error: onQueryError
  });
});

});

SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,349 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Amos Wu-MSFT 4,021 Reputation points
    2020-09-24T03:03:51.337+00:00

    You could try to run the following powershell command :

    $web = Get-SPWebApplication -Identity http://your web address  
    $web.ClientCallableSettings.AnonymousRestrictedTypes.Remove( [Microsoft.SharePoint.SPList],"GetItems")  
    $web.Update()  
    

    Source:
    https://sharepointinaction.wordpress.com/tag/sharepoint-powershell-anonymousrestrictedtypes/


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    No comments