Using Postman to test rest apis I'm getting all news posts from a few sites with this:
https://xxx.sharepoint.com/_api/search/query?querytext='SPContentType:"Site Page" AND IsDocument:True AND FileExtension:aspx AND PromotedState:2 AND Path:https://xxx.sharepoint.com/sites/xxx OR Path:https://xxx.sharepoint.com/sites/xxx OR Path:https://xxx.sharepoint.com/sites/xxx/SitePages'&sortlist='FirstPublishedDate:descending'&startRow=0&rowlimit=100&selectproperties='Title,Description,RefinableString03,FirstPublishedDate,PictureThumbnailURL,WebId,Path'
Now I need to limit the response to only those pages with a first published date occurring in the last 6 months. Can't use Today token in rest api calls and I've tried adding a variable in pre-request script:
var today = new Date();
today.setUTCHours(0,0,0,0);
And then adding this in a variety of ways using search or regular SP rest to the request url:
$filter=FirstPublishedDate le datetime'" + today.toISOString() + "';
but obviously that expression throws an error "not valid".


