SharePoint 2016 Logo

The queries to get all the list items, get list items with specific field values, get list items by ContentType Name. The most of the time I spend with the last one.

Get all the list items information and add it's ContentType:

Get all the list items information and add it's ContentType:'BookingObjects')/items?$select=Title,Id,ContentType/Name&$expand=ContentType

Get the list items and information about it's ContentType where Title == 'Hall 1''BookingObjects')/items?$select=Title,Id,ContentType/Name&$expand=ContentType&$filter=Title%20eq%20%27Hall%201%27

Get the list items with specific ContentType by Name (filter by ContentType name):'BookingObjects')/items?$select=Title,Id,ContentType/Name&$expand=ContentType&$filter=ContentType%20eq%20%27ConferenceRoom%27

Get the list items with multiple specific ContentTypes by Name (filter by ContentType name - where ContentType eq 'ConferenceRoom' or eq 'Equipment'):'BookingObjects')/items?$select=Title,Id,ContentType/Name&$expand=ContentType&$filter=ContentType%20eq%20%27ConferenceRoom%27 or ContentType%20eq%20%27Equipment%27

For pnpjs the code is something like this:

const res: any = await this._sp.web.lists.getByTitle('BookingObjects')'Id', 'Title', 'ContentType/Name').expand('ContentType').filter(`ContentType eq 'ConferenceRoom' or ContentType eq 'Equipment'`)();

Rest API request to determine if the time interval is free among the reservations for the booked item:'Reservation Events')/Items?$filter=((StartDate ge datetime'2023-07-13T10:00:00Z') and (EndDate le datetime'2023-07-20T14:00:00Z') and (StartDate ge datetime'2023-07-13T12:00:00Z') and (EndDate le datetime'2023-07-20T14:00:00Z')) and (BookObjectId eq 3)

Get all the items from the specific folder in SharePoint doclib
fetch("'VoteLib/Team1')?$select=Name&$expand=Folders,Files", {headers:{'Accept':'application/json'}})

PNPJs query to get all the folders at the top level

sp.web.lists.getByTitle(this._objectList).rootFolder.folders()).filter( x=>x.Name !== 'Forms')

PNPJS query how to retrieve the items by the Author in SharePoint List. As a name I use Email

await this._sp.web.lists.getByTitle(this._voteList)'Id', 'Title', 'Author/EMail', 'Author/Title').expand("Author").filter((Author/EMail eq '${userLogin}'))()

or REST API query to retrieve the items by the Author in SharePoint List'Votes')/items?$select=Title,Id,Author/EMail&$expand=Author