Not able to POST tag or task in Google Script

Running the following code gives error but don’t understand what is going wrong?

Error:
{“errors”:[{“message”:“You should specify one of workspace”,“help”:“For more information on API status codes and how to handle them, read the docs on errors: Build an app with Asana”}]}

Code:
function postTag() {
var res = UrlFetchApp.fetch(‘https://app.asana.com/api/1.0/tags’, {
method: ‘post’,
headers: {
‘Content-Type’: ‘application/json’,
//‘Accept’: ‘application/json’,
‘Authorization’: 'Bearer ’ + access_token,
},
body : JSON.stringify({
“data”: {
“color”: “light-green”,
“name”: “Stuff to buy”,
“workspace”: “1154002117252059”
}
}),
muteHttpExceptions: true
});
Logger.log(res);
}

Try “payload” instead of “body” parameter, as seen in this example:

1 Like

That did the trick. Next question is how to add priority to a task when adding it. Should this be done in the tags field?

Never mind, found it in custom fields.

1 Like