Hi,
I try to request all tasks from a project and to include the field ‘completed’ in the response. The following curl command is working and delivers the expected result:
url -H “Authorization: Bearer ” https://app.asana.com/api/1.0/projects/‘project-id’/tasks?opt_expand=completed
Now I try to get the same result via Google Apps Script:
function getTasks(){
var projectId = "'project-id'"; //Project ID
var token = "'token'"; //Asana Personal Access Token
var bearerToken = "Bearer " + token;
//Request
var request = {
data : {
opt_expand : ['completed']
}
};
// Request options
var options = {
"method" : "GET",
"headers" : {"Authorization": bearerToken},
"contentType": 'application/json',
"payload" : JSON.stringify(request)
};
Logger.log(options);
try {
var url = "https://app.asana.com/api/1.0/projects/" + projectId + "/tasks";
var result = UrlFetchApp.fetch(url, options);
var reqReturn = result.getContentText();
Logger.log(reqReturn);
}
catch (e) {
Logger.log(e);
}
}
Here I get the error message:
returned code 404. Truncated server response: {"errors":[{"message":"No matching route for request","help":"For more information on API status codes and how to handle them, read the docs on err... (use muteHttpExceptions option to examine full response)
If I do not use the ‘payload’ option I get a valid result, but then without the ‘completed’ field. Any ideas?
Thanks