使用Rest调用从Sharepoint在线页面库中读取控制台应用程序中的数据 [英] Read data in console app from Sharepoint online pages library using Rest calls
问题描述
我已经创建了一个控制台应用程序,并且我想在其中读取页面库"中页面的页面内容.
我需要在此处使用oAuth访问令牌进行身份验证.当我尝试对getItems进行Rest调用时,它不会返回任何数据
如果我使用其他休止电话,例如获取列表标题等,则可以.我在重命名clientid,client secret时已为此应用程序授予了所有必需的权限.我想我在进行REST调用以获取项目时缺少语法上的某些东西.我在看一些博客 并发现有些人在rest调用中使用@target不确定是否需要.下面是我正在使用的代码,但是在共振数组中它没有返回任何值.
感谢您的帮助!
HttpWebRequest请求=(HttpWebRequest)HttpWebRequest.Create(@``https://XXXXXXXXX.sharepoint.com/sites/homesite/_api/Web/Lists/getByTitle('Pages')/items?$ select = PublishingPageContent''') ;request.Method ="GET";
request.Accept ="application/json; odata = verbose";
request.Headers.Add("Authorization","Bearer" + accessToken);
HttpWebResponse响应=(HttpWebResponse)request.GetResponse();
StreamReader reader =新的StreamReader(response.GetResponseStream());
字符串response1 = reader.ReadToEnd();
谢谢
在我的SharePoint Online租户中,当按标题在浏览器中获取Pages库时,它将返回404 not found错误.
https://testlz.sharepoint.com/sites/jerrydev/_api/web/lists/getByTitle('Pages')/
我在下面用List GUID尝试获取列表项,并且它可以正常工作,因此请使用GUID get list而不是通过列表标题获取.
https://testlz.sharepoint.com/sites/jerrydev/_api/web/lists(guid'381129e1-4778-4c61-bb33-50372dc45428')/items(1)?
select = PublishingPageContent
var webUri =新的Uri("https://xxx.sharepoint.com/sites/jerrydev"); var userName ="xxx@xxx.onmicrosoft.com"; var password ="xxxx"; 使用(var client = new SPHttpClient(webUri,userName,password)) { var itemId = 1; var endpointUrl = string.Format("{0}/_ api/web/lists(guid'381129e1-4778-4c61-bb33-50372dc45428')/items({1})?
select = PublishingPageContent",webUri,itemId); var data = client.ExecuteJson(endpointUrl); }
谢谢
最好的问候
Hi ,
I have created a console app and in which i want to read page content of pages from "Pages library ".
I need to use oAuth access token here for authentication. When i try to make Rest call for getItems it doesn't return any data
if i use other rest call like get list title etc it works. I have given all required permission to this app while regitering clientid, client secrete. I think i am missing something in syntax while making rest call to get items. I was reading some blogs and found some people are using @target in rest call not sure if that is required. Below is the code which i am using butin resonse array it doesn't return any value.
Any help is appreciated !
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(@"https://XXXXXXXXX.sharepoint.com/sites/homesite/_api/Web/Lists/getByTitle('Pages')/items?$select=PublishingPageContent"");request.Method = "GET";
request.Accept = "application/json;odata=verbose";
request.Headers.Add("Authorization", "Bearer " + accessToken);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string response1 = reader.ReadToEnd();
Thanks
Hi,
In my SharePoint Online Tenant, when getting Pages library by Title in Browser, it will return 404 not found error.
https://testlz.sharepoint.com/sites/jerrydev/_api/web/lists/getByTitle('Pages')/I tried with below with List GUID to get list item and it works, so please use GUID get list instead getting by the list title.
https://testlz.sharepoint.com/sites/jerrydev/_api/web/lists(guid'381129e1-4778-4c61-bb33-50372dc45428')/items(1)?
select=PublishingPageContent
var webUri = new Uri("https://xxx.sharepoint.com/sites/jerrydev"); var userName = "xxx@xxx.onmicrosoft.com"; var password = "xxxx"; using (var client = new SPHttpClient(webUri, userName, password)) { var itemId = 1; var endpointUrl = string.Format("{0}/_api/web/lists(guid'381129e1-4778-4c61-bb33-50372dc45428')/items({1})?
select=PublishingPageContent", webUri,itemId); var data = client.ExecuteJson(endpointUrl); }
Thanks
Best Regards
这篇关于使用Rest调用从Sharepoint在线页面库中读取控制台应用程序中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!