Reputation: 145
I am trying to make a function that can search for a file/folder. If the file/folder exists then it will return the id else will return null from the drive in PHP, but every time I do this it shows that there is some error in q.
An error occurred: {
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Value",
"locationType": "parameter",
"location": "q"
}
],
"code": 400,
"message": "Invalid Value"
}
}
The query is:-
//testing-folder-of-api is the name of the folder
mimeType=application/vnd.google-apps.folder and name='testing-folder-of-api'
I also tried with changing it like:
mimeType!=application/vnd.google-apps.folder
if not a filename contains 'test.txt'
and title='test.txt'
for searching it by name.The solution that I found was that to loop through all the files and check the name individually using a loop which took to much time.
Can someone plz show me how to do it. Please!!
Upvotes: 1
Views: 798
Reputation: 19309
You should add single quotes around 'application/vnd.google-apps.folder'
, as mentioned at File-specific query terms:
mimeType: MIME type of the file. Surround with single quotes '.
mimeType='application/vnd.google-apps.folder' and name='testing-folder-of-api'
Upvotes: 1