I have an HTML5 + jQuery application with a built in contact form that I wanted to hook into Sharepoint, and Lists seemed an ideal way to do that. I used the jQuery library SPServices to get this up and running, and I thought it was working great with the following javascript code:
// Use Sharepoint list for adding data.
function CreateNewItem(name, email, phone, seat_chosen) {
// Time to try to submit the form to Sharepoint!
$().SPServices({
operation: "UpdateListItems",
async: false,
batchCmd: "New",
listName: "Form Contacts",
valuepairs: [["Title", name], ["Email", email], ["Phone", phone], ["Seat_Clicked", seat_chosen]],
completefunc: function(xData, status) {
if (status == "success") {
alert ("Thank you, " + $("#contact_name").val() + ", for your inquiry!" );
}
else {
alert ("Unable to submit your request at this time.");
}
}
});
}
But it turned out that this only works if you are authenticated/logged in, even though the List permissions is set to allow Anyonymous Add Items. If you aren't logged in you just get that soul-crushing 401 (Unauthorized) message from _vti_bin/Lists.asmx.
I found various references to this problem in Googling, but they were all numerous years old and started back with Sharepoint 2007 and SPServices .5 (now using .7.2), and most trails end alluding to some future version or update they hope will fix this and then...the trail goes cold.
Is there some way to accomplish adding items to a list anonymously without allowing the contents of the list to be viewed publicly? If I need to use something other than SPServices I can, but custom alteration of Sharepoint itself or it's server-side code is not doable in this case.
I'm really, really trying to stick with javascript to get this accomplished for a multitude of reasons.