Skip to content

Instantly share code, notes, and snippets.

@jeffdonthemic
Created February 16, 2023 20:25
Show Gist options
  • Save jeffdonthemic/280a4ffadfb4ff89edfca2af8343618e to your computer and use it in GitHub Desktop.
Save jeffdonthemic/280a4ffadfb4ff89edfca2af8343618e to your computer and use it in GitHub Desktop.
Apex REST GET
public with sharing class ClickUpTaskService {
private static String apiKey = '';
public static void call() {
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api.clickup.com/api/v2/list/900600512507/task');
request.setMethod('GET');
request.setHeader('Authorization', apiKey);
HttpResponse response = http.send(request);
List<ClickUpTask> tasks = new List<ClickUpTask>();
// If the request is successful, parse the JSON response.
if(response.getStatusCode() == 200) {
Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
// Cast the values in the 'tasks' key as a list
List<Object> resultsTasks = (List<Object>) results.get('tasks');
for(Object task: resultsTasks) {
tasks.add((ClickUpTask)(JSON.deserialize(JSON.serialize(task), ClickUpTask.class)));
}
}
System.debug(tasks.size());
}
public class ClickUpTask {
public String id;
public String name;
public String description;
public Boolean archived;
public String url;
public Map<String, String> status;
public Map<String, String> project;
public Map<String, String> folder;
public Map<String, String> space;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment