I tried your approach and was able to retrieve all the files with a particular extension from google drive API. I have developed the part of my code using python.
The Query I have used:
q=f"'{folder_id}' in parents and name contains '.extension' and trashed = false"
Also, I have used other field parameters while searching such as
kind,incompleteSearch,files/size,files/id,files/name
In python; the code will look something like the below:
extension_files = self.service.files().list(
q=f"'{folder_id}' in parents and \
name contains '.extension' and trashed = false",
fields='kind,incompleteSearch,files/size,files/id,files/name'
).execute()
Where service you have to set up by the Google drive access token using the build() and credentials.
Hope this will help you in solving your problem.