Reputation: 1
I have been following this tutorial to integrate google drive in my app. However error occurs when running the app.
The error:
The following error occured: 400 Bad Request
{
"code":400,
"errors":[{
"domain":"global",
"location":"fiels",
"locationType":"parameter",
"message": "Invalid field selection items",
"reason":"invalidParameter"
}],
"message":"Invalid field selection items"
}
When I debugged this code I found the code is not executing beyond:
private List<String> getDataFromApi() throws IOException {
// Get a list of up to 10 files.
List<String> fileInfo = new ArrayList<String>();
FileList result = mService.files().list()
.setPageSize(10)
.setFields("nextPageToken, items(id, name)")
.execute();
Here is the next step from the code that I have used:
List<com.google.api.services.drive.model.File> files = result.getFiles();
if (files != null) {
for (com.google.api.services.drive.model.File file : files) {
fileInfo.add(String.format("%s (%s)\n",
file.getName(),file.getId() ));
}
}
return fileInfo;
}
In the manifest I have defined:
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
and inside application in manifest:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.gms.games.APP_ID"
android:value="99102****479" />
<meta-data
android:name="com.google.android.gms.appstate.APP_ID"
android:value="99102****479" />
I don't know what the problem is. Please Help. Thank you.
Upvotes: 0
Views: 444
Reputation: 26
I did the same tutorial a couple of days ago and got same problem, some how they did not updated their tutorial since in this line:
.setFields("nextPageToken, items(id, name)")
have to be changed to
.setFields("nextPageToken, files(id, name)")
as they explain in the search for files section.
Hope this helps!
Upvotes: 1