Add Story To Task

In our Windows application, I am accessing all the comments made to a task and displaying them to the users. They would also like a way to add a comment from our application. I can’t find the exact syntax but I think it’s something like this: “/tasks/{0:Target}/stories”, “POST”. I have no idea what “Target” is.

To get the stories, I am issuing: response = GetResponse(String.Format(“{0}/stories?opt_pretty”, task));

So I am looking for a complement to that to add a story.

From the API docs - “Target” refers to the Task ID:

See here for more info and an example.

1 Like

Yes, thank you, I saw that.
What I need help with, if you know, is how to issue that request from my C#/Windows application. It would be the complement to GetResponse.

@MMOCK, here are the docs for commenting on a task (i.e. creating a story).

We don’t have any examples in C#, but the docs do have a cURL request example for making a comment:

curl -H "Authorization: Bearer <personal_access_token>" \ \
--data-urlencode "text=This is a very nice comment."

@MMOCK I’m using the AsanaNet project as the basis for my communications so I don’t have a simple code fragment I could give you; but I think something like the HTTPClient PostAsync example shown here should do the trick. Let us know how that goes.

1 Like

It went beautifully! Thank you!!!

I can’t recall where I found this function, but it went like this:

    public string GetResponse(string uri, string data = "", string method = "GET")
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

        // Create Request
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
        request.PreAuthenticate = true;
        request.Method = method;
        request.ContentType = "application/x-www-form-urlencoded";

        // Log In
        string authInfo = "0/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + ":" + "";
        authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
        request.Headers["Authorization"] = "Basic " + authInfo;

        // send data if supplied
        if (data != "")

        // receive response
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        return new StreamReader(response.GetResponseStream()).ReadToEnd();


So then I realized I just need to fill in the part when data is not blank so I can post my new asana comment. I googled “GetResponse(string uri, string data = “”, string method = “GET”)” to see if I could get back to where I found that, and it led me to c# - How to properly make a http web GET request - Stack Overflow. That gave me the missing block which is simply:

        // send data if supplied
        if (data != "")
            byte[] dataBytes = Encoding.UTF8.GetBytes(data);
            request.ContentLength = dataBytes.Length;
            using (Stream requestBody = request.GetRequestStream())
                requestBody.Write(dataBytes, 0, dataBytes.Length);


And I call into it:

    private void cmdAddStory_Click(object sender, EventArgs e)
        string response;
        response = GetResponse("", "text=This is my new comment", "POST");

In my response the StatusCode is Created so then I checked asana from the user end and there it is, my new comment!
So thank you, again!

Hello I Want To Add Stories With Task Using Api is It Possible? @Phil_Seeman

Hi @Vaibhav_Pancholi,

Yes, it’s possible. Specifically, there are two types of stories: system-generated stories that record updates to task information, and user-generated stories, that is, task comments.

You can’t add system-generated stories but you can add comments to tasks. See here for more info:

1 Like

@Phil_Seeman thanks for your reply but i want to know that is there any way to add comments while creating new task

Not in one API operation, no. You’ll have to create the task first, then add comments (stories) to it.

1 Like