I am trying to get time entries through ClickUp API using the google apps scripts.
function getTime()
{
const query = new URLSearchParams({
start_date: '0',
end_date: '0',
assignee: '0',
include_task_tags: 'true',
include_location_names: 'true',
space_id: '0',
folder_id: '0',
list_id: '0',
task_id: '0',
custom_task_ids: 'true',
team_id: '123'
}).toString();
const teamId = '123';
const resp = fetch(
`https://api.clickup.com/api/v2/team/${teamId}/time_entries?${query}`,
{
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: 'tk_49237802_NCN'
}
}
);
const data = resp.text();
console.log(data);
}
However it keeps on showing following error:
ReferenceError: URLSearchParams is not defined
Any reference or help will be highly appreciated
I think that your script is for Javascript. That is not Google Apps Script. By this, such an error like
ReferenceError: URLSearchParams is not defined
occurs. If you want to convert your Javascript to Google Apps Script, how about the following sample script?Sample script:
Please copy and paste the following script to the script editor of Google Apps Script, and save the script. And, please run
myFunction
. By this, the script is run.Note:
Authorization: 'tk_49237802_NCN'
, andquery
, and your URL, again.Reference: