Search REST query - filtering ModifiedBy by Current User

Iron Contributor



Trying to show the 10 most recent documents edited by the current user by calling the search REST api, but I am struggling with filtering the results by the current user. Using this call gives 0 results:




However if I use my actual name, I get the expected set of results:


/_api/search/query?querytext='(*)+AND+(path:"")+AND+(FileExtension:doc+OR+FileExtension:docx+OR+FileExtension:ppt+OR+FileExtension:pptx+OR+FileExtension:xls+OR+FileExtension:xlsx+OR+FileExtension:xlsm+OR+FileExtension:pdf)'&trimduplicates=false&refinementfilters='ModifiedBy:Nigel Witherdin'&clienttype='ContentSearchRegular'


Is there a token value I can use in this REST call, or should I be determining the current user's display name in the script myself and insert it into the REST call?








2 Replies
best response confirmed by Nigel Witherdin (Iron Contributor)

As described in this blog by @Mikael Svenson you can use Query Variables together with the REST api


Key here is to make use of QueryTemplate instead of QueryText.


Thanks Paul - you're a machine!