如何从 iOS 应用程序使用 REST API 对 Microsoft SharePoint 网站进行身份验证
我开始知道我们可以使用 REST api 从 SharePoint 网站获取数据。此外,SharePoint 从 2010 年起支持 REST。我从 SharePoint 获得了用于列出数据及其详细信息的 API。它是“ListData.svc”。是否有任何其他 API 类似于我们可以用来验证我们网站的 API。我尝试了浏览器(listdata.svc),在此之前我已登录。如果我注销并执行“siteUrl/_vti_bin/ListData.svc”,我将无法获得结果,请求超时或有时它显示网页不可用。如果有人知道如何在 iPhone 应用程序中使用 SharePoint 内容,请分享一些内容。
I came to know that we could use REST apis to get data from SharePoint sites. Also SharePoint supports REST from 2010 onwards. I got the API for listing the data and its details from SharePoint. It is "ListData.svc". Is there any other APIs similar to that using which we could authenticate our site. I tried it browser(listdata.svc) and before that I was logged in. If I am logged out and do the "siteUrl/_vti_bin/ListData.svc", I am not able to get the result, request getting timed out or sometimes it shows Webpage is not available. If anyone know how to SharePoint stuffs in iPhone application, please share something on the same.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
阅读此内容: http://sharepointsemantics.com/2011/07/the-client-side-object-model-help-with-headless-authentication-in-sharepoint-online/ 确保您阅读了 Chris Johnson 撰写的链接文章,按照其中的信息应该可以解决您的身份验证问题。
旁注,您几乎必须在 SharePoint 端使用表单身份验证。
Read this: http://sharepointsemantics.com/2011/07/the-client-side-object-model-help-with-headless-authentication-in-sharepoint-online/ Make sure you read the linked articles written by Chris Johnson, following the information there should solve your authentication woes.
Sidenote, you pretty much HAVE to use forms authentication on the SharePoint end.
以下是我通过 http 对 SharePoint 2010 进行 NTLM 身份验证的方法。它可以工作并从对 listdata.svc 的任何调用返回 JSON 字典(例如调用 URL yourdomain/_vti_bin/listdata.svc/YourList):
Grab AFNetworking 并按照说明将其放入您的 XCode 应用程序中。
当您在项目中编译 AFNetworking 时,您需要对 AFNetworking 框架的 AFHTTPClient 类进行子类化。例如,向您的 iOS XCode 项目添加一个新类,并选择 AFHTTPClient 作为其对象类型。
进行子类化后,您将获得如下内容:
YourHTTPClient.h
在 YourHTTPClient.m 文件中,您可以包含以下代码,但在此 .m 文件中,您将实现自定义方法调用以从 SharePoint 获取列表数据。请参见下文:
用于从 YourHTTPClient.m 进行身份验证的代码片段:
我仅在配置为使用 NTLM 进行身份验证的 SharePoint 2010 环境中尝试了上述操作。如果您需要使用 Kerberos 进行身份验证,可能需要重新配置,但我怀疑也可以使用 AFNetworking。
Here is the way I have done this for NTLM authentication to SharePoint 2010 over http. It works and returns JSON dictionary from any call to the listdata.svc (e.g. call to URL yourdomain/_vti_bin/listdata.svc/YourList):
Grab AFNetworking and follow the instructions to get it into your XCode application.
When you have AFNetworking compiling in your project you need to subclass AFHTTPClient class of AFNetworking framework. E.g. add a new class to your iOS XCode project and choose AFHTTPClient as it's object type.
Once you have subclassed you get something like the following:
YourHTTPClient.h
The in your YourHTTPClient.m file you could have the code below but in this .m file is where you will implement your custom method calls to get your list data from SharePoint. See below:
Code fragment for authentication from YourHTTPClient.m:
I have only tried the above with a SharePoint 2010 environment configured to authenticate using NTLM. It may need reconfiguration if you need to authenticate using Kerberos but I suspect it is possible also using AFNetworking.
看看这个项目,它支持 SharePoint 2013 RestAPI。它对我有用,并且非常确定它也对您有用。
默认情况下,SPRESTQuery 提供 XMl 格式的响应,如果您想要 json 格式的响应,则必须在executeQuery 方法中编写此行。
Look at this project, it supports SharePoint 2013 RestAPI.Its working for me, and very sure it will work for you also.
By default the SPRESTQuery provides the response in XMl, If you want response in json you will have to write this line in executeQuery Method.