1

I have a sharepoint 2010 website with anonymous access. here i want to add a list item to the list as anonymous user.am given whole website access to anonymous.when am trying to add list item am getting access denied error.am using sharepoint foundation 2010 version. here is my java script code.

 <script type="text/javascript">
    ExecuteOrDelayUntilScriptLoaded(MainFunction, "sp.js"); 
    function submit123(){
          createListItem();
    }
    function createListItem() {
           var clientContext = new SP.ClientContext.get_current();
           var oList = clientContext.get_web().get_lists().getByTitle('SIP');        
           var itemCreateInfo = new SP.ListItemCreationInformation();
           this.oListItem = oList.addItem(itemCreateInfo);        
           oListItem.set_item('Title', 'My New Item!');    
           oListItem.update();
           clientContext.load(oListItem);

           clientContext.executeQueryAsync(Function.createDelegate(this,  this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
       }

        function onQuerySucceeded() {
                alert('Item created: ' + oListItem.get_id());
        }

        function onQueryFailed(sender, args) {
                 alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
         } 

1

Please allow anonymous access on list also on which you want to add the listitem.

Here are the detailed steps:

http://blogs.technet.com/b/sharepointdevelopersupport/archive/2013/06/13/how-to-allow-anonymous-users-to-add-items-to-sharepoint-list-using-client-object-model.aspx

| improve this answer | |

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.