Skip to content

CorsoSource/AsanaNet

Repository files navigation

AsanaNet - the C# library for the Asana

This is the interface for interacting with the Asana Platform. Our API reference is generated from our [OpenAPI spec] (https://raw.githubusercontent.com/Asana/openapi/master/defs/asana_oas.yaml).

This C# SDK is automatically generated by the OpenAPI Generator project:

  • API version: 1.0
  • SDK version: 1.0.0
  • Generator version: 7.4.0
  • Build package: org.openapitools.codegen.languages.CSharpClientCodegen For more information, please visit https://asana.com/support

Frameworks supported

Dependencies

The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:

Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package System.ComponentModel.Annotations

NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742. NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See RestSharp#1406.

Installation

Run the following command to generate the DLL

  • [Mac/Linux] /bin/sh build.sh
  • [Windows] build.bat

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

using AsanaNet.Api;
using AsanaNet.Client;
using AsanaNet.Model;

Packaging

A .nuspec is included with the project. You can follow the Nuget quickstart to create and publish packages.

This .nuspec uses placeholders from the .csproj, so build the .csproj directly:

nuget pack -Build -OutputDirectory out AsanaNet.csproj

Then, publish to a local feed or other host and consume the new package via Nuget as usual.

Usage

To use the API client with a HTTP proxy, setup a System.Net.WebProxy

Configuration c = new Configuration();
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;

Getting Started

using System.Collections.Generic;
using System.Diagnostics;
using AsanaNet.Api;
using AsanaNet.Client;
using AsanaNet.Model;

namespace Example
{
    public class Example
    {
        public static void Main()
        {

            Configuration config = new Configuration();
            config.BasePath = "https://app.asana.com/api/1.0";
            // Configure Bearer token for authorization: personalAccessToken
            config.AccessToken = "YOUR_BEARER_TOKEN";
            // Configure OAuth2 access token for authorization: oauth2
            config.AccessToken = "YOUR_ACCESS_TOKEN";

            var apiInstance = new AttachmentsApi(config);
            var parent = "parent_example";  // string | Required identifier of the parent task, project, or project_brief, as a string. 
            var optPretty = true;  // bool? | Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. (optional) 
            var optFields = new List<string>?(); // List<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. (optional) 
            var resourceSubtype = "asana";  // string? | The type of the attachment. Must be one of the given values. If not specified, a file attachment of type `asana` will be assumed. Note that if the value of `resource_subtype` is `external`, a `parent`, `name`, and `url` must also be provided.  (optional) 
            var file = new System.IO.MemoryStream(System.IO.File.ReadAllBytes("/path/to/file.txt"));  // System.IO.Stream? | Required for `asana` attachments.  (optional) 
            var url = "url_example";  // string? | The URL of the external resource being attached. Required for attachments of type `external`.  (optional) 
            var name = "name_example";  // string? | The name of the external resource being attached. Required for attachments of type `external`.  (optional) 
            var connectToApp = true;  // bool? | *Optional*. Only relevant for external attachments with a parent task. A boolean indicating whether the current app should be connected with the attachment for the purposes of showing an app components widget. Requires the app to have been added to a project the parent task is in.  (optional) 

            try
            {
                // Upload an attachment
                GetAttachment200Response result = apiInstance.CreateAttachmentForObject(parent, optPretty, optFields, resourceSubtype, file, url, name, connectToApp);
                Debug.WriteLine(result);
            }
            catch (ApiException e)
            {
                Debug.Print("Exception when calling AttachmentsApi.CreateAttachmentForObject: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }

        }
    }
}

Documentation for API Endpoints

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

Class Method HTTP request Description
AttachmentsApi CreateAttachmentForObject POST /attachments Upload an attachment
AttachmentsApi DeleteAttachment DELETE /attachments/{attachment_gid} Delete an attachment
AttachmentsApi GetAttachment GET /attachments/{attachment_gid} Get an attachment
AttachmentsApi GetAttachmentsForObject GET /attachments Get attachments from an object
AuditLogAPIApi GetAuditLogEvents GET /workspaces/{workspace_gid}/audit_log_events Get audit log events
BatchAPIApi CreateBatchRequest POST /batch Submit parallel requests
CustomFieldSettingsApi GetCustomFieldSettingsForPortfolio GET /portfolios/{portfolio_gid}/custom_field_settings Get a portfolio's custom fields
CustomFieldSettingsApi GetCustomFieldSettingsForProject GET /projects/{project_gid}/custom_field_settings Get a project's custom fields
CustomFieldsApi CreateCustomField POST /custom_fields Create a custom field
CustomFieldsApi CreateEnumOptionForCustomField POST /custom_fields/{custom_field_gid}/enum_options Create an enum option
CustomFieldsApi DeleteCustomField DELETE /custom_fields/{custom_field_gid} Delete a custom field
CustomFieldsApi GetCustomField GET /custom_fields/{custom_field_gid} Get a custom field
CustomFieldsApi GetCustomFieldsForWorkspace GET /workspaces/{workspace_gid}/custom_fields Get a workspace's custom fields
CustomFieldsApi InsertEnumOptionForCustomField POST /custom_fields/{custom_field_gid}/enum_options/insert Reorder a custom field's enum
CustomFieldsApi UpdateCustomField PUT /custom_fields/{custom_field_gid} Update a custom field
CustomFieldsApi UpdateEnumOption PUT /enum_options/{enum_option_gid} Update an enum option
EventsApi GetEvents GET /events Get events on a resource
GoalRelationshipsApi AddSupportingRelationship POST /goals/{goal_gid}/addSupportingRelationship Add a supporting goal relationship
GoalRelationshipsApi GetGoalRelationship GET /goal_relationships/{goal_relationship_gid} Get a goal relationship
GoalRelationshipsApi GetGoalRelationships GET /goal_relationships Get goal relationships
GoalRelationshipsApi RemoveSupportingRelationship POST /goals/{goal_gid}/removeSupportingRelationship Removes a supporting goal relationship
GoalRelationshipsApi UpdateGoalRelationship PUT /goal_relationships/{goal_relationship_gid} Update a goal relationship
GoalsApi AddFollowers POST /goals/{goal_gid}/addFollowers Add a collaborator to a goal
GoalsApi CreateGoal POST /goals Create a goal
GoalsApi CreateGoalMetric POST /goals/{goal_gid}/setMetric Create a goal metric
GoalsApi DeleteGoal DELETE /goals/{goal_gid} Delete a goal
GoalsApi GetGoal GET /goals/{goal_gid} Get a goal
GoalsApi GetGoals GET /goals Get goals
GoalsApi GetParentGoalsForGoal GET /goals/{goal_gid}/parentGoals Get parent goals from a goal
GoalsApi RemoveFollowers POST /goals/{goal_gid}/removeFollowers Remove a collaborator from a goal
GoalsApi UpdateGoal PUT /goals/{goal_gid} Update a goal
GoalsApi UpdateGoalMetric POST /goals/{goal_gid}/setMetricCurrentValue Update a goal metric
JobsApi GetJob GET /jobs/{job_gid} Get a job by id
MembershipsApi CreateMembership POST /memberships Create a membership
MembershipsApi DeleteMembership DELETE /memberships/{membership_gid} Delete a membership
MembershipsApi GetMembership GET /memberships/{membership_gid} Get a membership
MembershipsApi GetMemberships GET /memberships Get multiple memberships
OrganizationExportsApi CreateOrganizationExport POST /organization_exports Create an organization export request
OrganizationExportsApi GetOrganizationExport GET /organization_exports/{organization_export_gid} Get details on an org export request
PortfolioMembershipsApi GetPortfolioMembership GET /portfolio_memberships/{portfolio_membership_gid} Get a portfolio membership
PortfolioMembershipsApi GetPortfolioMemberships GET /portfolio_memberships Get multiple portfolio memberships
PortfolioMembershipsApi GetPortfolioMembershipsForPortfolio GET /portfolios/{portfolio_gid}/portfolio_memberships Get memberships from a portfolio
PortfoliosApi AddCustomFieldSettingForPortfolio POST /portfolios/{portfolio_gid}/addCustomFieldSetting Add a custom field to a portfolio
PortfoliosApi AddItemForPortfolio POST /portfolios/{portfolio_gid}/addItem Add a portfolio item
PortfoliosApi AddMembersForPortfolio POST /portfolios/{portfolio_gid}/addMembers Add users to a portfolio
PortfoliosApi CreatePortfolio POST /portfolios Create a portfolio
PortfoliosApi DeletePortfolio DELETE /portfolios/{portfolio_gid} Delete a portfolio
PortfoliosApi GetItemsForPortfolio GET /portfolios/{portfolio_gid}/items Get portfolio items
PortfoliosApi GetPortfolio GET /portfolios/{portfolio_gid} Get a portfolio
PortfoliosApi GetPortfolios GET /portfolios Get multiple portfolios
PortfoliosApi RemoveCustomFieldSettingForPortfolio POST /portfolios/{portfolio_gid}/removeCustomFieldSetting Remove a custom field from a portfolio
PortfoliosApi RemoveItemForPortfolio POST /portfolios/{portfolio_gid}/removeItem Remove a portfolio item
PortfoliosApi RemoveMembersForPortfolio POST /portfolios/{portfolio_gid}/removeMembers Remove users from a portfolio
PortfoliosApi UpdatePortfolio PUT /portfolios/{portfolio_gid} Update a portfolio
ProjectBriefsApi CreateProjectBrief POST /projects/{project_gid}/project_briefs Create a project brief
ProjectBriefsApi DeleteProjectBrief DELETE /project_briefs/{project_brief_gid} Delete a project brief
ProjectBriefsApi GetProjectBrief GET /project_briefs/{project_brief_gid} Get a project brief
ProjectBriefsApi UpdateProjectBrief PUT /project_briefs/{project_brief_gid} Update a project brief
ProjectMembershipsApi GetProjectMembership GET /project_memberships/{project_membership_gid} Get a project membership
ProjectMembershipsApi GetProjectMembershipsForProject GET /projects/{project_gid}/project_memberships Get memberships from a project
ProjectStatusesApi CreateProjectStatusForProject POST /projects/{project_gid}/project_statuses Create a project status
ProjectStatusesApi DeleteProjectStatus DELETE /project_statuses/{project_status_gid} Delete a project status
ProjectStatusesApi GetProjectStatus GET /project_statuses/{project_status_gid} Get a project status
ProjectStatusesApi GetProjectStatusesForProject GET /projects/{project_gid}/project_statuses Get statuses from a project
ProjectTemplatesApi DeleteProjectTemplate DELETE /project_templates/{project_template_gid} Delete a project template
ProjectTemplatesApi GetProjectTemplate GET /project_templates/{project_template_gid} Get a project template
ProjectTemplatesApi GetProjectTemplates GET /project_templates Get multiple project templates
ProjectTemplatesApi GetProjectTemplatesForTeam GET /teams/{team_gid}/project_templates Get a team's project templates
ProjectTemplatesApi InstantiateProject POST /project_templates/{project_template_gid}/instantiateProject Instantiate a project from a project template
ProjectsApi AddCustomFieldSettingForProject POST /projects/{project_gid}/addCustomFieldSetting Add a custom field to a project
ProjectsApi AddFollowersForProject POST /projects/{project_gid}/addFollowers Add followers to a project
ProjectsApi AddMembersForProject POST /projects/{project_gid}/addMembers Add users to a project
ProjectsApi CreateProject POST /projects Create a project
ProjectsApi CreateProjectForTeam POST /teams/{team_gid}/projects Create a project in a team
ProjectsApi CreateProjectForWorkspace POST /workspaces/{workspace_gid}/projects Create a project in a workspace
ProjectsApi DeleteProject DELETE /projects/{project_gid} Delete a project
ProjectsApi DuplicateProject POST /projects/{project_gid}/duplicate Duplicate a project
ProjectsApi GetProject GET /projects/{project_gid} Get a project
ProjectsApi GetProjects GET /projects Get multiple projects
ProjectsApi GetProjectsForTask GET /tasks/{task_gid}/projects Get projects a task is in
ProjectsApi GetProjectsForTeam GET /teams/{team_gid}/projects Get a team's projects
ProjectsApi GetProjectsForWorkspace GET /workspaces/{workspace_gid}/projects Get all projects in a workspace
ProjectsApi GetTaskCountsForProject GET /projects/{project_gid}/task_counts Get task count of a project
ProjectsApi ProjectSaveAsTemplate POST /projects/{project_gid}/saveAsTemplate Create a project template from a project
ProjectsApi RemoveCustomFieldSettingForProject POST /projects/{project_gid}/removeCustomFieldSetting Remove a custom field from a project
ProjectsApi RemoveFollowersForProject POST /projects/{project_gid}/removeFollowers Remove followers from a project
ProjectsApi RemoveMembersForProject POST /projects/{project_gid}/removeMembers Remove users from a project
ProjectsApi UpdateProject PUT /projects/{project_gid} Update a project
RulesApi TriggerRule POST /rule_triggers/{rule_trigger_gid}/run Trigger a rule
SectionsApi AddTaskForSection POST /sections/{section_gid}/addTask Add task to section
SectionsApi CreateSectionForProject POST /projects/{project_gid}/sections Create a section in a project
SectionsApi DeleteSection DELETE /sections/{section_gid} Delete a section
SectionsApi GetSection GET /sections/{section_gid} Get a section
SectionsApi GetSectionsForProject GET /projects/{project_gid}/sections Get sections in a project
SectionsApi InsertSectionForProject POST /projects/{project_gid}/sections/insert Move or Insert sections
SectionsApi UpdateSection PUT /sections/{section_gid} Update a section
StatusUpdatesApi CreateStatusForObject POST /status_updates Create a status update
StatusUpdatesApi DeleteStatus DELETE /status_updates/{status_update_gid} Delete a status update
StatusUpdatesApi GetStatus GET /status_updates/{status_update_gid} Get a status update
StatusUpdatesApi GetStatusesForObject GET /status_updates Get status updates from an object
StoriesApi CreateStoryForTask POST /tasks/{task_gid}/stories Create a story on a task
StoriesApi DeleteStory DELETE /stories/{story_gid} Delete a story
StoriesApi GetStoriesForTask GET /tasks/{task_gid}/stories Get stories from a task
StoriesApi GetStory GET /stories/{story_gid} Get a story
StoriesApi UpdateStory PUT /stories/{story_gid} Update a story
TagsApi CreateTag POST /tags Create a tag
TagsApi CreateTagForWorkspace POST /workspaces/{workspace_gid}/tags Create a tag in a workspace
TagsApi DeleteTag DELETE /tags/{tag_gid} Delete a tag
TagsApi GetTag GET /tags/{tag_gid} Get a tag
TagsApi GetTags GET /tags Get multiple tags
TagsApi GetTagsForTask GET /tasks/{task_gid}/tags Get a task's tags
TagsApi GetTagsForWorkspace GET /workspaces/{workspace_gid}/tags Get tags in a workspace
TagsApi UpdateTag PUT /tags/{tag_gid} Update a tag
TaskTemplatesApi DeleteTaskTemplate DELETE /task_templates/{task_template_gid} Delete a task template
TaskTemplatesApi GetTaskTemplate GET /task_templates/{task_template_gid} Get a task template
TaskTemplatesApi GetTaskTemplates GET /task_templates Get multiple task templates
TaskTemplatesApi InstantiateTask POST /task_templates/{task_template_gid}/instantiateTask Instantiate a task from a task template
TasksApi AddDependenciesForTask POST /tasks/{task_gid}/addDependencies Set dependencies for a task
TasksApi AddDependentsForTask POST /tasks/{task_gid}/addDependents Set dependents for a task
TasksApi AddFollowersForTask POST /tasks/{task_gid}/addFollowers Add followers to a task
TasksApi AddProjectForTask POST /tasks/{task_gid}/addProject Add a project to a task
TasksApi AddTagForTask POST /tasks/{task_gid}/addTag Add a tag to a task
TasksApi CreateSubtaskForTask POST /tasks/{task_gid}/subtasks Create a subtask
TasksApi CreateTask POST /tasks Create a task
TasksApi DeleteTask DELETE /tasks/{task_gid} Delete a task
TasksApi DuplicateTask POST /tasks/{task_gid}/duplicate Duplicate a task
TasksApi GetDependenciesForTask GET /tasks/{task_gid}/dependencies Get dependencies from a task
TasksApi GetDependentsForTask GET /tasks/{task_gid}/dependents Get dependents from a task
TasksApi GetSubtasksForTask GET /tasks/{task_gid}/subtasks Get subtasks from a task
TasksApi GetTask GET /tasks/{task_gid} Get a task
TasksApi GetTaskForCustomID GET /workspaces/{workspace_gid}/tasks/custom_id/{custom_id} Get a task for a given custom ID
TasksApi GetTasks GET /tasks Get multiple tasks
TasksApi GetTasksForProject GET /projects/{project_gid}/tasks Get tasks from a project
TasksApi GetTasksForSection GET /sections/{section_gid}/tasks Get tasks from a section
TasksApi GetTasksForTag GET /tags/{tag_gid}/tasks Get tasks from a tag
TasksApi GetTasksForUserTaskList GET /user_task_lists/{user_task_list_gid}/tasks Get tasks from a user task list
TasksApi RemoveDependenciesForTask POST /tasks/{task_gid}/removeDependencies Unlink dependencies from a task
TasksApi RemoveDependentsForTask POST /tasks/{task_gid}/removeDependents Unlink dependents from a task
TasksApi RemoveFollowerForTask POST /tasks/{task_gid}/removeFollowers Remove followers from a task
TasksApi RemoveProjectForTask POST /tasks/{task_gid}/removeProject Remove a project from a task
TasksApi RemoveTagForTask POST /tasks/{task_gid}/removeTag Remove a tag from a task
TasksApi SearchTasksForWorkspace GET /workspaces/{workspace_gid}/tasks/search Search tasks in a workspace
TasksApi SetParentForTask POST /tasks/{task_gid}/setParent Set the parent of a task
TasksApi UpdateTask PUT /tasks/{task_gid} Update a task
TeamMembershipsApi GetTeamMembership GET /team_memberships/{team_membership_gid} Get a team membership
TeamMembershipsApi GetTeamMemberships GET /team_memberships Get team memberships
TeamMembershipsApi GetTeamMembershipsForTeam GET /teams/{team_gid}/team_memberships Get memberships from a team
TeamMembershipsApi GetTeamMembershipsForUser GET /users/{user_gid}/team_memberships Get memberships from a user
TeamsApi AddUserForTeam POST /teams/{team_gid}/addUser Add a user to a team
TeamsApi CreateTeam POST /teams Create a team
TeamsApi GetTeam GET /teams/{team_gid} Get a team
TeamsApi GetTeamsForUser GET /users/{user_gid}/teams Get teams for a user
TeamsApi GetTeamsForWorkspace GET /workspaces/{workspace_gid}/teams Get teams in a workspace
TeamsApi RemoveUserForTeam POST /teams/{team_gid}/removeUser Remove a user from a team
TeamsApi UpdateTeam PUT /teams/{team_gid} Update a team
TimePeriodsApi GetTimePeriod GET /time_periods/{time_period_gid} Get a time period
TimePeriodsApi GetTimePeriods GET /time_periods Get time periods
TimeTrackingEntriesApi CreateTimeTrackingEntry POST /tasks/{task_gid}/time_tracking_entries Create a time tracking entry
TimeTrackingEntriesApi DeleteTimeTrackingEntry DELETE /time_tracking_entries/{time_tracking_entry_gid} Delete a time tracking entry
TimeTrackingEntriesApi GetTimeTrackingEntriesForTask GET /tasks/{task_gid}/time_tracking_entries Get time tracking entries for a task
TimeTrackingEntriesApi GetTimeTrackingEntry GET /time_tracking_entries/{time_tracking_entry_gid} Get a time tracking entry
TimeTrackingEntriesApi UpdateTimeTrackingEntry PUT /time_tracking_entries/{time_tracking_entry_gid} Update a time tracking entry
TypeaheadApi TypeaheadForWorkspace GET /workspaces/{workspace_gid}/typeahead Get objects via typeahead
UserTaskListsApi GetUserTaskList GET /user_task_lists/{user_task_list_gid} Get a user task list
UserTaskListsApi GetUserTaskListForUser GET /users/{user_gid}/user_task_list Get a user's task list
UsersApi GetFavoritesForUser GET /users/{user_gid}/favorites Get a user's favorites
UsersApi GetUser GET /users/{user_gid} Get a user
UsersApi GetUsers GET /users Get multiple users
UsersApi GetUsersForTeam GET /teams/{team_gid}/users Get users in a team
UsersApi GetUsersForWorkspace GET /workspaces/{workspace_gid}/users Get users in a workspace or organization
WebhooksApi CreateWebhook POST /webhooks Establish a webhook
WebhooksApi DeleteWebhook DELETE /webhooks/{webhook_gid} Delete a webhook
WebhooksApi GetWebhook GET /webhooks/{webhook_gid} Get a webhook
WebhooksApi GetWebhooks GET /webhooks Get multiple webhooks
WebhooksApi UpdateWebhook PUT /webhooks/{webhook_gid} Update a webhook
WorkspaceMembershipsApi GetWorkspaceMembership GET /workspace_memberships/{workspace_membership_gid} Get a workspace membership
WorkspaceMembershipsApi GetWorkspaceMembershipsForUser GET /users/{user_gid}/workspace_memberships Get workspace memberships for a user
WorkspaceMembershipsApi GetWorkspaceMembershipsForWorkspace GET /workspaces/{workspace_gid}/workspace_memberships Get the workspace memberships for a workspace
WorkspacesApi AddUserForWorkspace POST /workspaces/{workspace_gid}/addUser Add a user to a workspace or organization
WorkspacesApi GetWorkspace GET /workspaces/{workspace_gid} Get a workspace
WorkspacesApi GetWorkspaces GET /workspaces Get multiple workspaces
WorkspacesApi RemoveUserForWorkspace POST /workspaces/{workspace_gid}/removeUser Remove a user from a workspace or organization
WorkspacesApi UpdateWorkspace PUT /workspaces/{workspace_gid} Update a workspace

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

personalAccessToken

  • Type: Bearer Authentication

oauth2

  • Type: OAuth
  • Flow: accessCode
  • Authorization URL: https://app.asana.com/-/oauth_authorize
  • Scopes:
    • default: Provides access to all endpoints documented in our API reference. If no scopes are requested, this scope is assumed by default.
    • openid: Provides access to OpenID Connect ID tokens and the OpenID Connect user info endpoint.
    • email: Provides access to the user’s email through the OpenID Connect user info endpoint.
    • profile: Provides access to the user’s name and profile photo through the OpenID Connect user info endpoint.

Releases

No releases published

Packages

No packages published

Languages