I m trying to make a REST API call to SharePoint Online from a Java application where i want to get all the files in the Sharepoint site along with its custom metadata.
 
If i use the following query it gets me all the files based on the filter specified but it doesn't fetch all the items fields i.e. file metadata  :

"https://example.com/sites/sitename/_api/Web/GetFolderByServerRelativeUrl('/sites/sitename')/Files?$expand=Files&$filter=TimeLastModified%20gt%20datetime'2016-8-20T09:59:32'"


Now if i use this query below it get me all the metadata of the files but the filter doesnt work and it returns all the files in the folder instead of the fetching the ones based on the filter=TimeLastModified.

"https://example.com/sites/sitename/_api/Web/GetFolderByServerRelativeUrl('/sites/foldername')?$expand=Files/ListItemAllFields&$filter=TimeLastModified%20gt%20datetime'2017-5-20T09:59:32'"

Can someone please guide me how can i fetch the files based on the filter=TimeLastModified which also retrieves all "ListItemAllFields"  so that it gets all the file's metadata as well at the same time.

Any help/pointers regarding this will be greatly appreciated!!!

Thanks in Advance.