Sharepoint rest api how to get list within url - sharepoint

I'm new to Sharepoint.
We created a page in Sharepoint, it contains 4 list items.
https://abc.sharepoint.com/teams/OneTeam/SitePages/Newsfeed-page.aspx
I tried to use
https://abc.sharepoint.com/teams/OneTeam/_api/Web/lists/getbytitle('Site Pages')/items?filter=PromotedState eq 2&$select=BannerImageUrl,Description,Title
But I got all the list with the Site Pages ( which is expected ).
My question is how can I get these 4 items only from the above page ( Newsfeed-page.aspx )?

R.R.
It looks like you forgot the $ before the $filter query parameter.
Can you try this instead:
_api/Web/lists/getbytitle('Site Pages')/items?$filter=PromotedState eq 2&$select=BannerImageUrl,Description,Title
That should give you all published news post pages.

Related

ViewPath query parameter in SharePoint list causes CSOM to fail Lists.GetById

It seems due to a recent SharePoint Online update that their lists (when selected using the left navigation) now adds a ViewPath query parameter by default. With this change, it seems like the Provider Hosted App redirect now sends a different ListId and not the Id for the actual list. When I use CSOM to resolve the ListId it results in a "Site Pages" and not the list at all.
clientContext.Web.Lists.GetById(ListId);
This code base did work before the recent SharePoint Online update but now I cannot call my list. If I manually remove the ViewPath query parameter from the list then the redirect shows the correct ListId and CSOM resolves the correct List. The problem is I cannot expect users to manually remove that query parameter.
If I navigate to the list by using the Site Content page and not the left navigation then this query parameter is not present and my application works.
Does anyone have context or direction into how to handle this new change?
I have a similar issue on our site. Instead of modifying the list, a script web part on the initial page seems to bleed through. I have ammended the links in the lefthand nav bar in an attempt to circumvent the viewpath query being added. I put in 2 url carriage returns on the end of the link. So far so good for me.

Microsoft Graph API SharePoint search

I have been trying to search through my SharePoint site. I am able to get results for a single drive:
xxx.sharepoint.com,xxxxxx-xxxx-xxxx-xxxx-xxxxxx,xxxxx-xxxx-xxxx-xxxx-xxxxxx/drives/xxxxxxxxx/search(q='{content}')
But if I do the same search at drive/root, I don't get any result:
xxx.sharepoint.com,xxxxxx-xxxx-xxxx-xxxx-xxxxxx,xxxxx-xxxx-xxxx-xxxx-xxxxxx/drive/root/search(q='{content}')
We basically want to perform a search across the entire subsite.
Hey a bit late but I've just discovered you can use the /sites endpoint to retrieve all items in a site by expanding relationships of graph objects. Could you try use:
https://graph.microsoft.com/v1.0/sites/root/sites?$expand=lists($expand=items)
This seems to return all list items in all subsites under the root site. You should hopefully then be able to to filter further by subsite, list, field values etc.

SharePoint 2013 Query for specific content type

I am trying to get the Search Content Web Part to display an aggregation of announcements from various announcement lists in a site collection.
I created the announcement lists using the "add an app" then "Announcements" so I am assuming that this is a list of the ContentType Announcement? I've added a new announcement to the list with a title of "this is a test".
After I have added the Search Content Web Part to a page (for test purposes a page in the same site as the announcement list) and gone to set the Query on the web part to:
ContentType:0x0104*
No results are being returned. To check that the announcement has been indexed by the crawler changed the query to:
Title:this is a test
Now two results are displayed 1 a csv and the other the announcement with a ending with ../DispForm.aspx?ID=1 .
Any help much appreciated.
Use ContentTypeId. I know that by default ContentType is shown this way, but it might be a bug. Just try ContentTypeId.

How can I search through a single sharepoint List in a site collection using Search Scope?

I have added a Web Address rule to a Search Scope and set the Folder url to the following for searching through a single list in site collection :-
http://svrmosstest3/sites/asmtportal/Lists/SearchList
And added this scope to the search dropdown, this search is working fine and will return results from that list only, but it returns one extra item which is an entry for the list itself which is :-
http://svrmosstest3/sites/asmtportal/Lists/SearchList/AllItems.aspx
because this will always fall under the Rule URL.
Is there any other method to create a search scope that will search only through the items of a Single Sharepoint List in a site collection ??
Please tell me ,.. if there are any sharepoint experts ??
You will most likely need to add a crawl rule to exclude that one page from being added to the index (which will then prevent it from being included in your search scope).

Filter a Content Query Web Part using the values of another web part on the same page

I have a Content Query Web Part on my page that rolls up all the contacts lists from all the sub-webs in my site collection. this works fine. I'd like to be able dynamically filter the contacts rollup by having the user click on a list of leters of the aphhabet at the top of the page. click A and see the contacts that start with A, etc...
I'm plopping various filter web parts on the page, but don't see how to filter the results of the CQWP. The connections menu is not much help.
You can't use the OOB filter webparts or CQWP like that.
What you can do is extend the CQWP and add some functionality to it - take a look at Enhanced Content Query Web Part over at codeplex.com for inspiration.
Then send the clicked letter to the QueryString and have your extended CQWP read the filter value from the querystring - this would perform really well
Generally, this sort of thing requires some development. Here's one source:
http://www.andrewconnell.com/blog/archive/2008/02/18/Subclassing-the-Content-Query-Web-Part-Adding-Dynamic-Filtering.aspx
i would not recommend you to use a cqwp....instead try using a dataview web part it allows you to filter the content using querystring parameters without coding.

Resources