1

I am trying to update an item in SharePoint list. I am logged in as anonymous user. It's a farm solution visual webpart, and I have this code:

  values["__metadata"] = { "type": "SP.Data.ServicesListItem" };
        var itemData = JSON.stringify(values);
        var headers = {
            'X-HTTP-Method':'PATCH',
            'If-Match': '*',
            "X-RequestDigest": $("#__REQUESTDIGEST").val()
        };
        var dfd = $.ajax({
            url: encodeURI(updateUrl),
            type: "POST",
            contentType: "application/json;odata=verbose",
            data: itemData,
            headers: headers
        });

It's working for the administrator, but for anonymous, no.

I have this added in my ascx file but it's not working:

   <SharePoint:FormDigest ID="FormDigest1" runat="server"></SharePoint:FormDigest>

Any idea?

  • Have you given the permission for Require Use Remote Interfaces permission ? Which steps you have done for anonymous access? – Dikesh Gandhi Dec 7 '16 at 6:21
3

Try below steps to enable CSOM for Anonymous users:

First give permissions at Web application level

Steps:

  1. Go to Central Administration
  2. Go to Manage Web Application
  3. Select your Web App
  4. Click on Authentication Providers in the ribbon
  5. Click zone "Default".
  6. Uncheck "Require Use Remote Interfaces Permission"

Give permissions on site

Steps:

  • Go to Site Settings --> Site Permissions.
  • Click the Anonymous Access button in the ribbon.
  • Uncheck the check-box for Require Use Remote Interfaces permission.
  • Click OK.

Give permissions on the list

Steps:

  • Go to List Settings --> Permissions for this list.
  • Stop Inheriting Permissions --> click OK
  • For Anonymous access, give Add or Edit permissions.

Reference:

Hope this will help you.

  • I have anonymous access enabled for the entire site. The require use remote interfaces permissions in "unchekced". What else could be the problem? – Jacky Dec 7 '16 at 12:00
  • The list shows that it's inheriting permissions from the parent, but the permission levels are set to "View Items" Shouldn't it allow update as well? – Jacky Dec 7 '16 at 12:02
  • Please also check these settings in central admin for that web application also. – Dikesh Gandhi Dec 7 '16 at 12:09
  • The settings in the site collection override the settings in central administration ... – Jacky Dec 7 '16 at 12:28
  • Shouldn't my list permissions for anonymous be: Allow Create, Update? It shows only "View Items" – Jacky Dec 7 '16 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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