I'm building a Android app that sync tasks to google tasks. And i used the Google Tasks APIs. My question is what parameters can I use in TasksRequest.setFields(String fields)? I see the sample code uses "items/title". What if i want to get other fields or what if i want to get multiple fields at the same time?
Asked
Active
Viewed 1,216 times
2 Answers
3
The format of this string is described here: https://developers.google.com/discovery/v1/performance#partial-response
And the APIs Explorer can help you build the string as well using a UI: https://developers.google.com/apis-explorer

Jason Hall
- 20,632
- 4
- 50
- 57
1
You must be referring to this snippet of code from the Google Tasks API sample for Android:
@Override
protected List<String> doInBackground(Void... arg0) {
try {
List<String> result = new ArrayList<String>();
com.google.api.services.tasks.Tasks.TasksOperations.List listRequest = service.tasks().list("@default");
listRequest.setFields("items/title,items/notes,items/completed");
//listRequest.setFields("items/title");
List<Task> tasks = listRequest.execute().getItems();
if (tasks != null) {
for (Task task : tasks) {
result.add(task.getTitle());
}
} else {
result.add("No tasks.");
}
return result;
} catch (IOException e) {
tasksSample.handleGoogleException(e);
return Collections.singletonList(e.getMessage());
} finally {
tasksSample.onRequestCompleted();
}
}
The documentation is very unclear about this, but this link gave me a clue.
Notice that I use
"items/title,items/notes,items/completed"
If you get the strings wrong, you will get
invalidParameter and Invalid field selection note

Eugene van der Merwe
- 4,390
- 1
- 35
- 48
-
@Chris.Zou this answer is more helpful to me than the accepted answer – Fuhrmanator Sep 21 '18 at 03:03