Socket
Book a DemoInstallSign in
Socket

asana-preview

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asana-preview

This_is_the_interface_for_interacting_with_the__Asana_Platform_httpsdevelopers_asana_com__Our_API_reference_is_generated_from_our__OpenAPI_spec__httpsraw_githubusercontent_comAsanaopenapimasterdefsasana_oas_yaml_

1.2.39
latest
Source
npmnpm
Version published
Weekly downloads
165
205.56%
Maintainers
1
Weekly downloads
 
Created
Source

asana-preview GitHub release NPM Version

This is a preview version of Asana's new node client library. For feedback and feature requests, please leave a comment on this forum thread or through the feedback form on our documentation site

  • API version: 1.0
  • Package version: 1.2.39

Installation

For Node.js

npm install from npmjs

npm install asana-preview --save

For browser

Include the latest release directly from GitHub:

<script src="https://github.com/Asana/node-asana-preview/releases/download/v1.2.39/asana-min.js"></script>

Example usage (NOTE: be careful not to expose your access token):

<script>
    let client = AsanaPreview.ApiClient.instance;
    let token = client.authentications['token'];
    token.accessToken = '<YOUR_ACCESS_TOKEN>';

    let usersApiInstance = new AsanaPreview.UsersApi();
    let user_gid = "me";
    let opts = {};

    usersApiInstance.getUser(user_gid, opts).then((result) => {
        console.log('API called successfully. Returned data: ' +  JSON.stringify(result.data, null, 2));
    }, (error) => {
        console.error(error.response.body);
    });
</script>

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

let usersApiInstance = new AsanaPreview.UsersApi();
let user_gid = "me"; // String | A string identifying a user. This can either be the string \"me\", an email, or the gid of a user.
let opts = { 
    "opt_fields": "email,name,photo,photo.image_1024x1024,photo.image_128x128,photo.image_21x21,photo.image_27x27,photo.image_36x36,photo.image_60x60,workspaces,workspaces.name" // [String] | This endpoint returns a compact resource, which excludes some properties by default. To include those optional properties, set this query parameter to a comma-separated list of the properties you wish to include.
};

usersApiInstance.getUser(user_gid, opts).then((result) => {
    console.log('API called successfully. Returned data: ' +  JSON.stringify(result.data, null, 2));
}, (error) => {
    console.error(error.response.body);
});

Example: GET, POST, PUT, DELETE on tasks

GET - get multiple tasks

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

let tasksApiInstance = new AsanaPreview.TasksApi();
let opts = { 
    "limit": 50, // Number | Results per page. The number of objects to return per page. The value must be between 1 and 100.
    "project": "<YOUR_PROJECT_GID>", // String | The project to filter tasks on.
    "modified_since": "2012-02-22T02:06:58.158Z", // Date | Only return tasks that have been modified since the given time.  *Note: A task is considered “modified” if any of its properties change, or associations between it and other objects are modified (e.g.  a task being added to a project). A task is not considered modified just because another object it is associated with (e.g. a subtask) is modified. Actions that count as modifying the task include assigning, renaming, completing, and adding stories.*
    "opt_fields": "actual_time_minutes,approval_status,assignee,assignee.name,assignee_section,assignee_section.name,assignee_status,completed,completed_at,completed_by,completed_by.name,created_at,created_by,custom_fields,custom_fields.asana_created_field,custom_fields.created_by,custom_fields.created_by.name,custom_fields.currency_code,custom_fields.custom_label,custom_fields.custom_label_position,custom_fields.date_value,custom_fields.date_value.date,custom_fields.date_value.date_time,custom_fields.description,custom_fields.display_value,custom_fields.enabled,custom_fields.enum_options,custom_fields.enum_options.color,custom_fields.enum_options.enabled,custom_fields.enum_options.name,custom_fields.enum_value,custom_fields.enum_value.color,custom_fields.enum_value.enabled,custom_fields.enum_value.name,custom_fields.format,custom_fields.has_notifications_enabled,custom_fields.is_formula_field,custom_fields.is_global_to_workspace,custom_fields.is_value_read_only,custom_fields.multi_enum_values,custom_fields.multi_enum_values.color,custom_fields.multi_enum_values.enabled,custom_fields.multi_enum_values.name,custom_fields.name,custom_fields.number_value,custom_fields.people_value,custom_fields.people_value.name,custom_fields.precision,custom_fields.resource_subtype,custom_fields.text_value,custom_fields.type,dependencies,dependents,due_at,due_on,external,external.data,followers,followers.name,hearted,hearts,hearts.user,hearts.user.name,html_notes,is_rendered_as_separator,liked,likes,likes.user,likes.user.name,memberships,memberships.project,memberships.project.name,memberships.section,memberships.section.name,modified_at,name,notes,num_hearts,num_likes,num_subtasks,offset,parent,parent.created_by,parent.name,parent.resource_subtype,path,permalink_url,projects,projects.name,resource_subtype,start_at,start_on,tags,tags.name,uri,workspace,workspace.name" // [String] | This endpoint returns a compact resource, which excludes some properties by default. To include those optional properties, set this query parameter to a comma-separated list of the properties you wish to include.
};

// GET - get multiple tasks
tasksApiInstance.getTasks(opts).then((result) => {
    console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));
}, (error) => {
    console.error(error.response.body);
});

POST - create a task

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

let tasksApiInstance = new AsanaPreview.TasksApi();
let body = {
    "data": {
        "name": "New Task",
        "approval_status": "pending",
        "assignee_status": "upcoming",
        "completed": false,
        "external": {
            "gid": "1234",
            "data": "A blob of information.",
        },
        "html_notes": "<body>Mittens <em>really</em> likes the stuff from Humboldt.</body>",
        "is_rendered_as_separator": false,
        "liked": true,
        "assignee": "me",
        "projects": ["<YOUR_PROJECT_GID>"],
    },
};
let opts = {};

// POST - Create a task
tasksApiInstance.createTask(body, opts).then((result) => {
    console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));
}, (error) => {
    console.error(error.response.body);
});

PUT - update a task

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

let tasksApiInstance = new AsanaPreview.TasksApi();
let task_gid = "<YOUR_TASK_GID>";
let body = {
    "data": {
        "name": "Updated Task",
    },
};
let opts = {};

// PUT - Update a task
tasksApiInstance.updateTask(body, task_gid, opts).then((result) => {
    console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));
}, (error) => {
    console.error(error.response.body);
});

DELETE - delete a task

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

let tasksApiInstance = new AsanaPreview.TasksApi();
let task_gid = "<YOUR_TASK_GID>";

// DELETE - Delete a task
tasksApiInstance.deleteTask(task_gid).then((result) => {
    console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));
}, (error) => {
    console.error(error.response.body);
});

Documentation for API Endpoints

All URIs are relative to https://app.asana.com/api/1.0

ClassMethodHTTP requestDescription
AsanaPreview.AttachmentsApicreateAttachmentForObjectPOST /attachmentsUpload an attachment
AsanaPreview.AttachmentsApideleteAttachmentDELETE /attachments/{attachment_gid}Delete an attachment
AsanaPreview.AttachmentsApigetAttachmentGET /attachments/{attachment_gid}Get an attachment
AsanaPreview.AttachmentsApigetAttachmentsForObjectGET /attachmentsGet attachments from an object
AsanaPreview.AuditLogAPIApigetAuditLogEventsGET /workspaces/{workspace_gid}/audit_log_eventsGet audit log events
AsanaPreview.BatchAPIApicreateBatchRequestPOST /batchSubmit parallel requests
AsanaPreview.CustomFieldSettingsApigetCustomFieldSettingsForPortfolioGET /portfolios/{portfolio_gid}/custom_field_settingsGet a portfolio's custom fields
AsanaPreview.CustomFieldSettingsApigetCustomFieldSettingsForProjectGET /projects/{project_gid}/custom_field_settingsGet a project's custom fields
AsanaPreview.CustomFieldsApicreateCustomFieldPOST /custom_fieldsCreate a custom field
AsanaPreview.CustomFieldsApicreateEnumOptionForCustomFieldPOST /custom_fields/{custom_field_gid}/enum_optionsCreate an enum option
AsanaPreview.CustomFieldsApideleteCustomFieldDELETE /custom_fields/{custom_field_gid}Delete a custom field
AsanaPreview.CustomFieldsApigetCustomFieldGET /custom_fields/{custom_field_gid}Get a custom field
AsanaPreview.CustomFieldsApigetCustomFieldsForWorkspaceGET /workspaces/{workspace_gid}/custom_fieldsGet a workspace's custom fields
AsanaPreview.CustomFieldsApiinsertEnumOptionForCustomFieldPOST /custom_fields/{custom_field_gid}/enum_options/insertReorder a custom field's enum
AsanaPreview.CustomFieldsApiupdateCustomFieldPUT /custom_fields/{custom_field_gid}Update a custom field
AsanaPreview.CustomFieldsApiupdateEnumOptionPUT /enum_options/{enum_option_gid}Update an enum option
AsanaPreview.EventsApigetEventsGET /eventsGet events on a resource
AsanaPreview.GoalRelationshipsApiaddSupportingRelationshipPOST /goals/{goal_gid}/addSupportingRelationshipAdd a supporting goal relationship
AsanaPreview.GoalRelationshipsApigetGoalRelationshipGET /goal_relationships/{goal_relationship_gid}Get a goal relationship
AsanaPreview.GoalRelationshipsApigetGoalRelationshipsGET /goal_relationshipsGet goal relationships
AsanaPreview.GoalRelationshipsApiremoveSupportingRelationshipPOST /goals/{goal_gid}/removeSupportingRelationshipRemoves a supporting goal relationship
AsanaPreview.GoalRelationshipsApiupdateGoalRelationshipPUT /goal_relationships/{goal_relationship_gid}Update a goal relationship
AsanaPreview.GoalsApiaddFollowersPOST /goals/{goal_gid}/addFollowersAdd a collaborator to a goal
AsanaPreview.GoalsApicreateGoalPOST /goalsCreate a goal
AsanaPreview.GoalsApicreateGoalMetricPOST /goals/{goal_gid}/setMetricCreate a goal metric
AsanaPreview.GoalsApideleteGoalDELETE /goals/{goal_gid}Delete a goal
AsanaPreview.GoalsApigetGoalGET /goals/{goal_gid}Get a goal
AsanaPreview.GoalsApigetGoalsGET /goalsGet goals
AsanaPreview.GoalsApigetParentGoalsForGoalGET /goals/{goal_gid}/parentGoalsGet parent goals from a goal
AsanaPreview.GoalsApiremoveFollowersPOST /goals/{goal_gid}/removeFollowersRemove a collaborator from a goal
AsanaPreview.GoalsApiupdateGoalPUT /goals/{goal_gid}Update a goal
AsanaPreview.GoalsApiupdateGoalMetricPOST /goals/{goal_gid}/setMetricCurrentValueUpdate a goal metric
AsanaPreview.JobsApigetJobGET /jobs/{job_gid}Get a job by id
AsanaPreview.MembershipsApicreateMembershipPOST /membershipsCreate a membership
AsanaPreview.MembershipsApideleteMembershipDELETE /memberships/{membership_gid}Delete a membership
AsanaPreview.MembershipsApigetMembershipGET /memberships/{membership_gid}Get a membership
AsanaPreview.MembershipsApigetMembershipsGET /membershipsGet multiple memberships
AsanaPreview.OrganizationExportsApicreateOrganizationExportPOST /organization_exportsCreate an organization export request
AsanaPreview.OrganizationExportsApigetOrganizationExportGET /organization_exports/{organization_export_gid}Get details on an org export request
AsanaPreview.PortfolioMembershipsApigetPortfolioMembershipGET /portfolio_memberships/{portfolio_membership_gid}Get a portfolio membership
AsanaPreview.PortfolioMembershipsApigetPortfolioMembershipsGET /portfolio_membershipsGet multiple portfolio memberships
AsanaPreview.PortfolioMembershipsApigetPortfolioMembershipsForPortfolioGET /portfolios/{portfolio_gid}/portfolio_membershipsGet memberships from a portfolio
AsanaPreview.PortfoliosApiaddCustomFieldSettingForPortfolioPOST /portfolios/{portfolio_gid}/addCustomFieldSettingAdd a custom field to a portfolio
AsanaPreview.PortfoliosApiaddItemForPortfolioPOST /portfolios/{portfolio_gid}/addItemAdd a portfolio item
AsanaPreview.PortfoliosApiaddMembersForPortfolioPOST /portfolios/{portfolio_gid}/addMembersAdd users to a portfolio
AsanaPreview.PortfoliosApicreatePortfolioPOST /portfoliosCreate a portfolio
AsanaPreview.PortfoliosApideletePortfolioDELETE /portfolios/{portfolio_gid}Delete a portfolio
AsanaPreview.PortfoliosApigetItemsForPortfolioGET /portfolios/{portfolio_gid}/itemsGet portfolio items
AsanaPreview.PortfoliosApigetPortfolioGET /portfolios/{portfolio_gid}Get a portfolio
AsanaPreview.PortfoliosApigetPortfoliosGET /portfoliosGet multiple portfolios
AsanaPreview.PortfoliosApiremoveCustomFieldSettingForPortfolioPOST /portfolios/{portfolio_gid}/removeCustomFieldSettingRemove a custom field from a portfolio
AsanaPreview.PortfoliosApiremoveItemForPortfolioPOST /portfolios/{portfolio_gid}/removeItemRemove a portfolio item
AsanaPreview.PortfoliosApiremoveMembersForPortfolioPOST /portfolios/{portfolio_gid}/removeMembersRemove users from a portfolio
AsanaPreview.PortfoliosApiupdatePortfolioPUT /portfolios/{portfolio_gid}Update a portfolio
AsanaPreview.ProjectBriefsApicreateProjectBriefPOST /projects/{project_gid}/project_briefsCreate a project brief
AsanaPreview.ProjectBriefsApideleteProjectBriefDELETE /project_briefs/{project_brief_gid}Delete a project brief
AsanaPreview.ProjectBriefsApigetProjectBriefGET /project_briefs/{project_brief_gid}Get a project brief
AsanaPreview.ProjectBriefsApiupdateProjectBriefPUT /project_briefs/{project_brief_gid}Update a project brief
AsanaPreview.ProjectMembershipsApigetProjectMembershipGET /project_memberships/{project_membership_gid}Get a project membership
AsanaPreview.ProjectMembershipsApigetProjectMembershipsForProjectGET /projects/{project_gid}/project_membershipsGet memberships from a project
AsanaPreview.ProjectStatusesApicreateProjectStatusForProjectPOST /projects/{project_gid}/project_statusesCreate a project status
AsanaPreview.ProjectStatusesApideleteProjectStatusDELETE /project_statuses/{project_status_gid}Delete a project status
AsanaPreview.ProjectStatusesApigetProjectStatusGET /project_statuses/{project_status_gid}Get a project status
AsanaPreview.ProjectStatusesApigetProjectStatusesForProjectGET /projects/{project_gid}/project_statusesGet statuses from a project
AsanaPreview.ProjectTemplatesApideleteProjectTemplateDELETE /project_templates/{project_template_gid}Delete a project template
AsanaPreview.ProjectTemplatesApigetProjectTemplateGET /project_templates/{project_template_gid}Get a project template
AsanaPreview.ProjectTemplatesApigetProjectTemplatesGET /project_templatesGet multiple project templates
AsanaPreview.ProjectTemplatesApigetProjectTemplatesForTeamGET /teams/{team_gid}/project_templatesGet a team's project templates
AsanaPreview.ProjectTemplatesApiinstantiateProjectPOST /project_templates/{project_template_gid}/instantiateProjectInstantiate a project from a project template
AsanaPreview.ProjectsApiaddCustomFieldSettingForProjectPOST /projects/{project_gid}/addCustomFieldSettingAdd a custom field to a project
AsanaPreview.ProjectsApiaddFollowersForProjectPOST /projects/{project_gid}/addFollowersAdd followers to a project
AsanaPreview.ProjectsApiaddMembersForProjectPOST /projects/{project_gid}/addMembersAdd users to a project
AsanaPreview.ProjectsApicreateProjectPOST /projectsCreate a project
AsanaPreview.ProjectsApicreateProjectForTeamPOST /teams/{team_gid}/projectsCreate a project in a team
AsanaPreview.ProjectsApicreateProjectForWorkspacePOST /workspaces/{workspace_gid}/projectsCreate a project in a workspace
AsanaPreview.ProjectsApideleteProjectDELETE /projects/{project_gid}Delete a project
AsanaPreview.ProjectsApiduplicateProjectPOST /projects/{project_gid}/duplicateDuplicate a project
AsanaPreview.ProjectsApigetProjectGET /projects/{project_gid}Get a project
AsanaPreview.ProjectsApigetProjectsGET /projectsGet multiple projects
AsanaPreview.ProjectsApigetProjectsForTaskGET /tasks/{task_gid}/projectsGet projects a task is in
AsanaPreview.ProjectsApigetProjectsForTeamGET /teams/{team_gid}/projectsGet a team's projects
AsanaPreview.ProjectsApigetProjectsForWorkspaceGET /workspaces/{workspace_gid}/projectsGet all projects in a workspace
AsanaPreview.ProjectsApigetTaskCountsForProjectGET /projects/{project_gid}/task_countsGet task count of a project
AsanaPreview.ProjectsApiprojectSaveAsTemplatePOST /projects/{project_gid}/saveAsTemplateCreate a project template from a project
AsanaPreview.ProjectsApiremoveCustomFieldSettingForProjectPOST /projects/{project_gid}/removeCustomFieldSettingRemove a custom field from a project
AsanaPreview.ProjectsApiremoveFollowersForProjectPOST /projects/{project_gid}/removeFollowersRemove followers from a project
AsanaPreview.ProjectsApiremoveMembersForProjectPOST /projects/{project_gid}/removeMembersRemove users from a project
AsanaPreview.ProjectsApiupdateProjectPUT /projects/{project_gid}Update a project
AsanaPreview.RulesApitriggerRulePOST /rule_triggers/{rule_trigger_gid}/runTrigger a rule
AsanaPreview.SectionsApiaddTaskForSectionPOST /sections/{section_gid}/addTaskAdd task to section
AsanaPreview.SectionsApicreateSectionForProjectPOST /projects/{project_gid}/sectionsCreate a section in a project
AsanaPreview.SectionsApideleteSectionDELETE /sections/{section_gid}Delete a section
AsanaPreview.SectionsApigetSectionGET /sections/{section_gid}Get a section
AsanaPreview.SectionsApigetSectionsForProjectGET /projects/{project_gid}/sectionsGet sections in a project
AsanaPreview.SectionsApiinsertSectionForProjectPOST /projects/{project_gid}/sections/insertMove or Insert sections
AsanaPreview.SectionsApiupdateSectionPUT /sections/{section_gid}Update a section
AsanaPreview.StatusUpdatesApicreateStatusForObjectPOST /status_updatesCreate a status update
AsanaPreview.StatusUpdatesApideleteStatusDELETE /status_updates/{status_update_gid}Delete a status update
AsanaPreview.StatusUpdatesApigetStatusGET /status_updates/{status_update_gid}Get a status update
AsanaPreview.StatusUpdatesApigetStatusesForObjectGET /status_updatesGet status updates from an object
AsanaPreview.StoriesApicreateStoryForTaskPOST /tasks/{task_gid}/storiesCreate a story on a task
AsanaPreview.StoriesApideleteStoryDELETE /stories/{story_gid}Delete a story
AsanaPreview.StoriesApigetStoriesForTaskGET /tasks/{task_gid}/storiesGet stories from a task
AsanaPreview.StoriesApigetStoryGET /stories/{story_gid}Get a story
AsanaPreview.StoriesApiupdateStoryPUT /stories/{story_gid}Update a story
AsanaPreview.TagsApicreateTagPOST /tagsCreate a tag
AsanaPreview.TagsApicreateTagForWorkspacePOST /workspaces/{workspace_gid}/tagsCreate a tag in a workspace
AsanaPreview.TagsApideleteTagDELETE /tags/{tag_gid}Delete a tag
AsanaPreview.TagsApigetTagGET /tags/{tag_gid}Get a tag
AsanaPreview.TagsApigetTagsGET /tagsGet multiple tags
AsanaPreview.TagsApigetTagsForTaskGET /tasks/{task_gid}/tagsGet a task's tags
AsanaPreview.TagsApigetTagsForWorkspaceGET /workspaces/{workspace_gid}/tagsGet tags in a workspace
AsanaPreview.TagsApiupdateTagPUT /tags/{tag_gid}Update a tag
AsanaPreview.TaskTemplatesApideleteTaskTemplateDELETE /task_templates/{task_template_gid}Delete a task template
AsanaPreview.TaskTemplatesApigetTaskTemplateGET /task_templates/{task_template_gid}Get a task template
AsanaPreview.TaskTemplatesApigetTaskTemplatesGET /task_templatesGet multiple task templates
AsanaPreview.TaskTemplatesApiinstantiateTaskPOST /task_templates/{task_template_gid}/instantiateTaskInstantiate a task from a task template
AsanaPreview.TasksApiaddDependenciesForTaskPOST /tasks/{task_gid}/addDependenciesSet dependencies for a task
AsanaPreview.TasksApiaddDependentsForTaskPOST /tasks/{task_gid}/addDependentsSet dependents for a task
AsanaPreview.TasksApiaddFollowersForTaskPOST /tasks/{task_gid}/addFollowersAdd followers to a task
AsanaPreview.TasksApiaddProjectForTaskPOST /tasks/{task_gid}/addProjectAdd a project to a task
AsanaPreview.TasksApiaddTagForTaskPOST /tasks/{task_gid}/addTagAdd a tag to a task
AsanaPreview.TasksApicreateSubtaskForTaskPOST /tasks/{task_gid}/subtasksCreate a subtask
AsanaPreview.TasksApicreateTaskPOST /tasksCreate a task
AsanaPreview.TasksApideleteTaskDELETE /tasks/{task_gid}Delete a task
AsanaPreview.TasksApiduplicateTaskPOST /tasks/{task_gid}/duplicateDuplicate a task
AsanaPreview.TasksApigetDependenciesForTaskGET /tasks/{task_gid}/dependenciesGet dependencies from a task
AsanaPreview.TasksApigetDependentsForTaskGET /tasks/{task_gid}/dependentsGet dependents from a task
AsanaPreview.TasksApigetSubtasksForTaskGET /tasks/{task_gid}/subtasksGet subtasks from a task
AsanaPreview.TasksApigetTaskGET /tasks/{task_gid}Get a task
AsanaPreview.TasksApigetTaskForCustomIDGET /workspaces/{workspace_gid}/tasks/custom_id/{custom_id}Get a task for a given custom ID
AsanaPreview.TasksApigetTasksGET /tasksGet multiple tasks
AsanaPreview.TasksApigetTasksForProjectGET /projects/{project_gid}/tasksGet tasks from a project
AsanaPreview.TasksApigetTasksForSectionGET /sections/{section_gid}/tasksGet tasks from a section
AsanaPreview.TasksApigetTasksForTagGET /tags/{tag_gid}/tasksGet tasks from a tag
AsanaPreview.TasksApigetTasksForUserTaskListGET /user_task_lists/{user_task_list_gid}/tasksGet tasks from a user task list
AsanaPreview.TasksApiremoveDependenciesForTaskPOST /tasks/{task_gid}/removeDependenciesUnlink dependencies from a task
AsanaPreview.TasksApiremoveDependentsForTaskPOST /tasks/{task_gid}/removeDependentsUnlink dependents from a task
AsanaPreview.TasksApiremoveFollowerForTaskPOST /tasks/{task_gid}/removeFollowersRemove followers from a task
AsanaPreview.TasksApiremoveProjectForTaskPOST /tasks/{task_gid}/removeProjectRemove a project from a task
AsanaPreview.TasksApiremoveTagForTaskPOST /tasks/{task_gid}/removeTagRemove a tag from a task
AsanaPreview.TasksApisearchTasksForWorkspaceGET /workspaces/{workspace_gid}/tasks/searchSearch tasks in a workspace
AsanaPreview.TasksApisetParentForTaskPOST /tasks/{task_gid}/setParentSet the parent of a task
AsanaPreview.TasksApiupdateTaskPUT /tasks/{task_gid}Update a task
AsanaPreview.TeamMembershipsApigetTeamMembershipGET /team_memberships/{team_membership_gid}Get a team membership
AsanaPreview.TeamMembershipsApigetTeamMembershipsGET /team_membershipsGet team memberships
AsanaPreview.TeamMembershipsApigetTeamMembershipsForTeamGET /teams/{team_gid}/team_membershipsGet memberships from a team
AsanaPreview.TeamMembershipsApigetTeamMembershipsForUserGET /users/{user_gid}/team_membershipsGet memberships from a user
AsanaPreview.TeamsApiaddUserForTeamPOST /teams/{team_gid}/addUserAdd a user to a team
AsanaPreview.TeamsApicreateTeamPOST /teamsCreate a team
AsanaPreview.TeamsApigetTeamGET /teams/{team_gid}Get a team
AsanaPreview.TeamsApigetTeamsForUserGET /users/{user_gid}/teamsGet teams for a user
AsanaPreview.TeamsApigetTeamsForWorkspaceGET /workspaces/{workspace_gid}/teamsGet teams in a workspace
AsanaPreview.TeamsApiremoveUserForTeamPOST /teams/{team_gid}/removeUserRemove a user from a team
AsanaPreview.TeamsApiupdateTeamPUT /teams/{team_gid}Update a team
AsanaPreview.TimePeriodsApigetTimePeriodGET /time_periods/{time_period_gid}Get a time period
AsanaPreview.TimePeriodsApigetTimePeriodsGET /time_periodsGet time periods
AsanaPreview.TimeTrackingEntriesApicreateTimeTrackingEntryPOST /tasks/{task_gid}/time_tracking_entriesCreate a time tracking entry
AsanaPreview.TimeTrackingEntriesApideleteTimeTrackingEntryDELETE /time_tracking_entries/{time_tracking_entry_gid}Delete a time tracking entry
AsanaPreview.TimeTrackingEntriesApigetTimeTrackingEntriesForTaskGET /tasks/{task_gid}/time_tracking_entriesGet time tracking entries for a task
AsanaPreview.TimeTrackingEntriesApigetTimeTrackingEntryGET /time_tracking_entries/{time_tracking_entry_gid}Get a time tracking entry
AsanaPreview.TimeTrackingEntriesApiupdateTimeTrackingEntryPUT /time_tracking_entries/{time_tracking_entry_gid}Update a time tracking entry
AsanaPreview.TypeaheadApitypeaheadForWorkspaceGET /workspaces/{workspace_gid}/typeaheadGet objects via typeahead
AsanaPreview.UserTaskListsApigetUserTaskListGET /user_task_lists/{user_task_list_gid}Get a user task list
AsanaPreview.UserTaskListsApigetUserTaskListForUserGET /users/{user_gid}/user_task_listGet a user's task list
AsanaPreview.UsersApigetFavoritesForUserGET /users/{user_gid}/favoritesGet a user's favorites
AsanaPreview.UsersApigetUserGET /users/{user_gid}Get a user
AsanaPreview.UsersApigetUsersGET /usersGet multiple users
AsanaPreview.UsersApigetUsersForTeamGET /teams/{team_gid}/usersGet users in a team
AsanaPreview.UsersApigetUsersForWorkspaceGET /workspaces/{workspace_gid}/usersGet users in a workspace or organization
AsanaPreview.WebhooksApicreateWebhookPOST /webhooksEstablish a webhook
AsanaPreview.WebhooksApideleteWebhookDELETE /webhooks/{webhook_gid}Delete a webhook
AsanaPreview.WebhooksApigetWebhookGET /webhooks/{webhook_gid}Get a webhook
AsanaPreview.WebhooksApigetWebhooksGET /webhooksGet multiple webhooks
AsanaPreview.WebhooksApiupdateWebhookPUT /webhooks/{webhook_gid}Update a webhook
AsanaPreview.WorkspaceMembershipsApigetWorkspaceMembershipGET /workspace_memberships/{workspace_membership_gid}Get a workspace membership
AsanaPreview.WorkspaceMembershipsApigetWorkspaceMembershipsForUserGET /users/{user_gid}/workspace_membershipsGet workspace memberships for a user
AsanaPreview.WorkspaceMembershipsApigetWorkspaceMembershipsForWorkspaceGET /workspaces/{workspace_gid}/workspace_membershipsGet the workspace memberships for a workspace
AsanaPreview.WorkspacesApiaddUserForWorkspacePOST /workspaces/{workspace_gid}/addUserAdd a user to a workspace or organization
AsanaPreview.WorkspacesApigetWorkspaceGET /workspaces/{workspace_gid}Get a workspace
AsanaPreview.WorkspacesApigetWorkspacesGET /workspacesGet multiple workspaces
AsanaPreview.WorkspacesApiremoveUserForWorkspacePOST /workspaces/{workspace_gid}/removeUserRemove a user from a workspace or organization
AsanaPreview.WorkspacesApiupdateWorkspacePUT /workspaces/{workspace_gid}Update a workspace

Optional fields

Our opt_fields feature allows you to request for properties of a resource that you want to be returned in the response (more information here).

NOTE: by default, endpoints that return an array of results (EX: Get multiple tasks, Get multiple projects), will return a compact version of those results (EX: Get multiple tasks returns an array of TaskCompact objects).

EX: Get multiple tasks / getTasks without opt_fields

Example Request

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

let tasksApiInstance = new AsanaPreview.TasksApi();
let opts = {
    "limit": 2,
    "project": "<YOUR_PROJECT_GID>"
};

// GET - get multiple tasks
tasksApiInstance.getTasks(opts).then((result) => {
    console.log(JSON.stringify(result.data, null, 2));
}, (error) => {
    console.error(error.response.body);
});

Example Response

[
  {
    "gid": "123",
    "name": "Task 1",
    "resource_type": "task",
    "resource_subtype": "default_task"
  },
  {
    "gid": "456",
    "name": "Task 2",
    "resource_type": "task",
    "resource_subtype": "default_task"
  }
]

EX: Get multiple tasks / getTasks with opt_fields

Example Request

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

let tasksApiInstance = new AsanaPreview.TasksApi();
let opts = { 
    "limit": 1,
    "project": "<YOUR_PROJECT_GID>",
    "opt_fields": "actual_time_minutes,approval_status,assignee,assignee.name,assignee_section,assignee_section.name,assignee_status,completed,completed_at,completed_by,completed_by.name,created_at,created_by,custom_fields,custom_fields.asana_created_field,custom_fields.created_by,custom_fields.created_by.name,custom_fields.currency_code,custom_fields.custom_label,custom_fields.custom_label_position,custom_fields.date_value,custom_fields.date_value.date,custom_fields.date_value.date_time,custom_fields.description,custom_fields.display_value,custom_fields.enabled,custom_fields.enum_options,custom_fields.enum_options.color,custom_fields.enum_options.enabled,custom_fields.enum_options.name,custom_fields.enum_value,custom_fields.enum_value.color,custom_fields.enum_value.enabled,custom_fields.enum_value.name,custom_fields.format,custom_fields.has_notifications_enabled,custom_fields.is_formula_field,custom_fields.is_global_to_workspace,custom_fields.is_value_read_only,custom_fields.multi_enum_values,custom_fields.multi_enum_values.color,custom_fields.multi_enum_values.enabled,custom_fields.multi_enum_values.name,custom_fields.name,custom_fields.number_value,custom_fields.people_value,custom_fields.people_value.name,custom_fields.precision,custom_fields.resource_subtype,custom_fields.text_value,custom_fields.type,dependencies,dependents,due_at,due_on,external,external.data,followers,followers.name,hearted,hearts,hearts.user,hearts.user.name,html_notes,is_rendered_as_separator,liked,likes,likes.user,likes.user.name,memberships,memberships.project,memberships.project.name,memberships.section,memberships.section.name,modified_at,name,notes,num_hearts,num_likes,num_subtasks,offset,parent,parent.created_by,parent.name,parent.resource_subtype,path,permalink_url,projects,projects.name,resource_subtype,start_at,start_on,tags,tags.name,uri,workspace,workspace.name"
};

// GET - get multiple tasks
tasksApiInstance.getTasks(opts).then((result) => {
    console.log(JSON.stringify(result.data, null, 2));
}, (error) => {
    console.error(error.response.body);
});

Example Response

[
  {
    "gid": "129839839",
    "actual_time_minutes": null,
    "assignee": {
      "gid": "120938293",
      "name": "user@example.com"
    },
    "assignee_status": "upcoming",
    "assignee_section": {
      "gid": "1094838938",
      "name": "Recently assigned"
    },
    "completed": false,
    "completed_at": null,
    "completed_by": null,
    "created_at": "2023-01-01T20:31:21.717Z",
    "created_by": {
      "gid": "1201784467042440",
      "resource_type": "user"
    },
    "custom_fields": [
      {
        "gid": "191859815",
        "enabled": true,
        "name": "Estimated time",
        "description": "Asana-created. Estimate time to complete a task.",
        "number_value": null,
        "precision": 0,
        "format": "duration",
        "currency_code": null,
        "custom_label": null,
        "created_by": null,
        "custom_label_position": null,
        "display_value": null,
        "resource_subtype": "number",
        "is_formula_field": false,
        "is_value_read_only": false,
        "type": "number"
      }
    ],
    "dependencies": [],
    "dependents": [],
    "due_at": "2025-01-20T02:06:58.000Z",
    "due_on": "2025-01-19",
    "followers": [
      {
        "gid": "120938293",
        "name": "user@example.com"
      }
    ],
    "hearted": true,
    "hearts": [
      {
        "gid": "594849843",
        "user": {
          "gid": "120938293",
          "name": "user@example.com"
        }
      }
    ],
    "html_notes": "<body>Example task notes</body>",
    "is_rendered_as_separator": false,
    "liked": true,
    "likes": [
      {
        "gid": "58303939",
        "user": {
          "gid": "120938293",
          "name": "user@example.com"
        }
      }
    ],
    "memberships": [
      {
        "project": {
          "gid": "4567",
          "name": "Example Project"
        },
        "section": {
          "gid": "8900",
          "name": "Untitled section"
        }
      }
    ],
    "modified_at": "2023-01-25T21:24:06.996Z",
    "name": "Task 1",
    "notes": "Example task notes",
    "num_hearts": 1,
    "num_likes": 1,
    "num_subtasks": 0,
    "parent": null,
    "permalink_url": "https://app.asana.com/0/58303939/129839839",
    "projects": [
      {
        "gid": "4567",
        "name": "Example Project"
      }
    ],
    "start_at": null,
    "start_on": null,
    "tags": [],
    "resource_subtype": "default_task",
    "workspace": {
      "gid": "111111",
      "name": "Example Workspace"
    }
  }
]

Pagination

By default, endpoints that return an array of results (EX: Get multiple tasks, Get multiple projects), will return a Collection object. This collection object contains a nextPage method that can be used to fetch for the next page of results. NOTE: in order to use nextPage you must have provided a limit query parameter argument in the initial request.

Use case

You may run into the following error when making a request to an endpoint that has >1000 results:

"The result is too large. You should use pagination (may require specifying a workspace)!"

In this scenario you will want to use pagaintion to gather your results. To do this, you will need to provide a limit query parameter argument in your request. This limit query param represents the number of results per page. NOTE: the limit can only be between 1 and 100.

EX: Pagination gather all resources

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

let tasksApiInstance = new AsanaPreview.TasksApi();
let opts = {
    "project": "<YOUR_PROJECT_GID>"
    "limit": 100
};

async function getAllTasks(opts) {
    let tasks = await tasksApiInstance.getTasks(opts).then(async (firstPage) => {
        let res = []
        res = res.concat(firstPage.data);
        // Get the next page
        let nextPage = await firstPage.nextPage();
        // Keep fetching for the next page until there are no more results
        while(nextPage.data) {
            res = res.concat(nextPage.data);
            nextPage = await nextPage.nextPage();
        }
        return res;
    }, (error) => {
        console.error(error.response.body);
    });
    // Do something with the tasks. EX: print out results
    console.log('Tasks: ' + JSON.stringify(tasks, null, 2));
}

getAllTasks(opts);

EX: Pagination do something per page

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

let tasksApiInstance = new AsanaPreview.TasksApi();
let opts = {
    'project': "<YOUR_PROJECT_GID>",
    'limit': 10
};

pageIndex = 1;

tasksApiInstance.getTasks(opts).then(async (firstPage) => {
    // Do something with the first <LIMIT> results. EX: print out results
    console.log(`Page ${pageIndex}: ` + JSON.stringify(firstPage.data, null, 2));

    // Get the next page
    let nextPage = await firstPage.nextPage();
    // Keep fetching for the next page until there are no more results
    while(nextPage.data) {
        // Do something with the next <LIMIT> results. EX: print out results
        pageIndex += 1;
        console.log(`Page ${pageIndex}: ` + JSON.stringify(nextPage.data, null, 2));
        // Get the next page
        nextPage = await nextPage.nextPage();
    }
}, (error) => {
    console.error(error.response.body);
});

Turning off Pagination

If you do not want a Collection object returned and want to implement your own pagination, you can disable pagination by setting RETURN_COLLECTION to false:

EX: Turning off pagination

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

// Turn off pagination
client.RETURN_COLLECTION = false;

let tasksApiInstance = new AsanaPreview.TasksApi();
let opts = {
    'project': "<YOUR_PROJECT_GID>",
    'limit': 1
};
tasksApiInstance.getTasks(opts).then((result) => {
    console.log('API called successfully. Returned data: ' + JSON.stringify(result, null, 2));
})

Sample response:

API called successfully. Returned data: {
  "data": [
    {
      "gid": "<TASK_GID>",
      "name": "Task 1",
      "resource_type": "task",
      "resource_subtype": "default_task"
    },
  ],
  "next_page": {
    "offset": "gjJl2xAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJib3JkZXJfcmHilbI6IltcIlZ5IixcIjlaWlhVMkkzUUdOoXcEIsMTIwNDYxNTc0NTypNDI3MF0iLCJpYXQiOjE2OTc4MjgsSkjjQsImV4cCI6MTY5NzgyOTM2NH0.5VuMfKvqexoEsKfoPFtayWBNWiKvfR7_hN6MJaaIkx8",
    "path": "/tasks?project=123456&limit=1&offset=gjJl2xAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJib3JkZXJfcmHilbI6IltcIlZ5IixcIjlaWlhVMkkzUUdOoXcEIsMTIwNDYxNTc0NTypNDI3MF0iLCJpYXQiOjE2OTc4MjgsSkjjQsImV4cCI6MTY5NzgyOTM2NH0.5VuMfKvqexoEsKfoPFtayWBNWiKvfR7_hN6MJaaIkx8",
    "uri": "https://app.asana.com/api/1.0/tasks?project=123456&limit=1&offset=gjJl2xAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJib3JkZXJfcmHilbI6IltcIlZ5IixcIjlaWlhVMkkzUUdOoXcEIsMTIwNDYxNTc0NTypNDI3MF0iLCJpYXQiOjE2OTc4MjgsSkjjQsImV4cCI6MTY5NzgyOTM2NH0.5VuMfKvqexoEsKfoPFtayWBNWiKvfR7_hN6MJaaIkx8"
  }
}

Getting events

In order to get events you will need a sync token. This sync token can be acquired in the error message from the initial request to getEvents.

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

let eventsApiInstance = new AsanaPreview.EventsApi();
let resource = "<YOUR_TASK_OR_PROJECT_GID>"; // String | A resource ID to subscribe to. The resource can be a task or project.
let opts = {
    "sync": ""
};
const timeouts = 5000

// Used to fetch for initial sync token
const setSyncToken = async () => {
    await eventsApiInstance.getEvents(resource, opts).then((result) => {
        console.log(JSON.stringify(result.data, null, 2));
    }, (error) => {
        let syncToken = error.response.body.sync;
        opts['sync'] = syncToken;
    });
}

const getEvents = async () => {
    console.log("Setting sync token");
    await setSyncToken();
    // Fetch for new events every 5 seconds
    console.log(`Fetching events every ${timeouts/1000} second(s)`);
    while(true) {
        await eventsApiInstance.getEvents(resource, opts).then((result) => {
            // Print response
            console.log(`Fetching events since sync: ${opts['sync']}`);
            console.log(JSON.stringify(result.data, null, 2));

            // Update the sync token with the new sync token provided in the response
            opts['sync'] = result._response.sync;
        }, (error) => {
            if (error.status === 412) {
                let syncToken = error.response.body.sync;
                opts['sync'] = syncToken;
                console.log(`412 error new sync token: ${syncToken}`);
            } else{
                console.error(error.response.text);
            }
        });
        await new Promise(resolve => setTimeout(resolve, timeouts));
    }
}

getEvents();

Accessing repsonse data

.
.
.
tasksApiInstance.getTask(task_gid, opts).then((task) => {
    let taskName = task.data.name;
    let taskNotes = task.data.notes;
    console.log(`taskName: ${taskName}`);
    console.log(`taskNotes: ${taskNotes}`);
}, (error) => {
    console.error(error.response.body);
});

Accessing response status code and headers

Use the <METHOD_NAME>WithHttpInfo (EX: getTaskWithHttpInfo) method to make a request that returns a response with headers.

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

let tasksApiInstance = new AsanaPreview.TasksApi();
let task_gid = "<YOUR_TASK_GID>";
let opts = {};

tasksApiInstance.getTaskWithHttpInfo(task_gid, opts).then((response_and_data) => {
    let data = response_and_data.data;
    let response = response_and_data.response;
    let task = data.data;
    let headers = response.headers;
    console.log(task);
    console.log(headers);
}, (error) => {
    console.error(error.response.body);
});

Adding deprecation flag: "asana-enable" or "asana-disable" header

EX: Asana-Enable header

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

// Add asana-enable header for the client
client.defaultHeaders['asana-enable'] = 'new_goal_memberships';

EX: Asana-Disable header

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

// Add asana-disable header for the client
client.defaultHeaders['asana-disable'] = 'new_goal_memberships';

Using the callApi method

Use the callApi method to make http calls when the endpoint does not exist in the current library version or has bugs

Example: GET, POST, PUT, DELETE on tasks

GET - get a task

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

// GET - get a task
client.callApi(
    path='/tasks/{task_gid}',
    httpMethod='GET',
    pathParams={"task_gid": "<YOUR_TASK_GID>"},
    queryParams={},
    headerParams={},
    formParams={},
    bodyParam=null,
    authNames=['token'],
    contentTypes=[],
    accepts=['application/json; charset=UTF-8'],
    returnType='Blob'
).then((response_and_data) => {
    let result = response_and_data.data;
    let task = result.data;
    console.log(task.name);
}, (error) => {
    console.error(error.response.body);
});

GET - get multiple tasks -> with opt_fields

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

// GET - get multiple tasks -> with opt_fields
client.callApi(
    path='/tasks',
    httpMethod='GET',
    pathParams={},
    queryParams={
        "limit": 50,
        "modified_since": '2012-02-22T02:06:58.158Z', // OR new Date("2012-02-22T02:06:58.158Z")
        "project": '<YOUR_PROJECT_GID>',
        "opt_fields": 'name,notes'
    },
    headerParams={},
    formParams={},
    bodyParam=null,
    authNames=['token'],
    contentTypes=[],
    accepts=['application/json; charset=UTF-8'],
    returnType='Blob'
).then((response_and_data) => {
    let result = response_and_data.data;
    let tasks = result.data;
    if (tasks.length > 0) {
        console.log(`Task 1 Name: ${tasks[0].name}`);
        console.log(`Task 1 Notes: ${tasks[0].notes}`);
    }
}, (error) => {
    console.error(error.response.body);
});

POST - create a task

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

// POST - create a task
client.callApi(
    path='/tasks',
    httpMethod='POST',
    pathParams={},
    queryParams={},
    headerParams={},
    formParams={},
    bodyParam={
        data: {
            "name": "New Task",
            "approval_status": "pending",
            "assignee_status": "upcoming",
            "completed": false,
            "html_notes": "<body>Mittens <em>really</em> likes the stuff from Humboldt.</body>",
            "is_rendered_as_separator": false,
            "liked": true,
            "assignee": "me",
            "projects": ["<YOUR_PROJECT_GID>"],
        }
    },
    authNames=['token'],
    contentTypes=[],
    accepts=['application/json; charset=UTF-8'],
    returnType='Blob'
).then((response_and_data) => {
    let result = response_and_data.data;
    let task = result.data;
    console.log(task.name);
}, (error) => {
    console.error(error.response.body);
});

PUT - update a task

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

// PUT - update a task
client.callApi(
    path='/tasks/{task_gid}',
    httpMethod='PUT',
    pathParams={task_gid: "<YOUR_TASK_GID>"},
    queryParams={},
    headerParams={},
    formParams={},
    bodyParam={
        "data": {
            "name": "Updated Task",
            "html_notes": "<body>Updated task notes</body>",
            "due_at": "2025-01-20T02:06:58.147Z"
        }
    },
    authNames=['token'],
    contentTypes=[],
    accepts=['application/json; charset=UTF-8'],
    returnType='Blob'
).then((response_and_data) => {
    let result = response_and_data.data;
    let task = result.data;
    console.log(task.name);
}, (error) => {
    console.error(error.response.body);
});

DELETE - delete a task

const AsanaPreview = require('asana-preview');

let client = AsanaPreview.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

// DELETE - delete a task
client.callApi(
    path='/tasks/{task_gid}',
    httpMethod='DELETE',
    pathParams={"task_gid": "<YOUR_TASK_GID>"},
    queryParams={},
    headerParams={},
    formParams={},
    bodyParam=null,
    authNames=['token'],
    contentTypes=[],
    accepts=['application/json; charset=UTF-8'],
    returnType='Blob'
).then((response_and_data) => {
    let result = response_and_data.data;
    let result = result.data;
    console.log(result);
}, (error) => {
    console.error(error.response.body);
});

FAQs

Package last updated on 13 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.