使用REST API获取Sharepoint 2013 List

时间:2015-09-04 06:58:23

标签: c# rest sharepoint sharepoint-2013 sharepoint-designer

我想使用移动设备从Sharepoint获取List因此我使用带有DefaultCredentials的REST API,我已经给了我的列表的读取权限但我得到了 远程服务器返回错误:(401)未经授权

我的代码是:

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("ListUrl");
request.Method = "GET";
request.Accept = "application/json;odata=verbose";
request.ContentType = "application/json;odata=verbose";
request.UseDefaultCredentials = true;
request.PreAuthenticate = true;
request.Credentials = System.Net.CredentialCache.DefaultCredentials;

这可以通过REST API实现,还是有其他解决方案? 有什么我想念的吗?

1 个答案:

答案 0 :(得分:1)

默认情况下,REST API仅限于经过身份验证的用户,因此您必须将其配置为匿名用户。您应该在网站集的根目录中上传查询属性模板,如Mastykarz的帖子所述:

http://blog.mastykarz.nl/configuring-sharepoint-2013-search-rest-api-anonymous-users/