I want to retrieve tasks in a specified status from a list in Clickup but I keep getting an empty response.
Resources - https://jsapi.apiary.io/apis/clickup20/reference/0/tasks/get-tasks.html In the api documentation, it says you can query by status using an array of statuses. Here's my code.
const clickupToken = "pk_*****************"
const clickupReqBody = { "Authorization": clickupToken }
const clickupUrl = "https://api.clickup.com/api/v2/"
function getTasks() {
var listId = "******";
var statusArray = ["Backlog","Open"];
var encodedStatusArray = encodeURIComponent(statusArray)
var urlAddition = "list/" + listId + "/task?archived=false&subtasks=true&statuses%5B%5D=" + encodedStatusArray
var params = {
"urlAddition": urlAddition,
"method": "GET"
}
var res = fetchClickupObject(params)
Logger.log(res)
}
function fetchClickupObject(params) {
var url = clickupUrl + params.urlAddition;
Logger.log(params)
var response = UrlFetchApp.fetch(url, {
"headers": clickupReqBody,
"method": params.method
});
return response;
}
I've tried all upper, lower, and proper casing for the statuses.
When I log res
it returns {"tasks":[]}
even though there are tasks in both the Backlog and Open statuses on clickup.
After some back and forth with the tech team at Clickup, they suggested I try to append status%5B%5D=statusName for each status I wanted to add. The working version looks like this.