0

Here's my api call to get news pages published on 2 sites in the last 60 days:

/_api/search/query?querytext='IsDocument:True AND FileExtension:aspx AND PromotedState:2 Path:https://xxx.sharepoint.com/sites/xxx Path:https://xxx.sharepoint.com/sites/xxx FirstPublishedDate>{Today-60}'

This works correctly in the results sources query builder, but when tested in Postman the date restriction is ignored.

Also curious about how to add a rowlimit to the api call to only return the latest say 5 results.

2 Answers 2

1

You could append &sortlist='FirstPublishedDate:descending'&startRow=0&rowlimit=5 to your request to sort response results and get the top five items.

You could know more about sharepoint search api here:

https://docs.microsoft.com/en-us/sharepoint/dev/general-development/sharepoint-search-rest-api-overview

1
  • Still returning out of scope results. Maybe I'm not getting the syntax right - you have a quote mark here after descending -- &sortlist= FirstPublishedDate:descending' -- was that a typo or closing the "querytext"?
    – matt
    Jul 8, 2020 at 19:48
0

This seems to work:

 /_api/search/query?querytext='IsDocument:True AND FileExtension:aspx AND PromotedState:2  Path:https://xxxx.sharepoint.com/sites/xxx Path:https://xxx.sharepoint.com/sites/xxxx'&sortlist='FirstPublishedDate:descending'&startRow=0&rowlimit=5

Msft should provide a few more examples illustrating how to concatenate various components.

1
  • Yes,that is right.
    – Amos
    Jul 9, 2020 at 1:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.