How to create a task in asana with bold description?

689 views Asked by At

I am able to create Project / task / attachment fine with Asana API with PHP. Is there a way to create Bold for Emphasis description for task / project ? I could not find that in Asana API. Can someone point me to right direction?

2

There are 2 answers

3
Marius On BEST ANSWER

I can confirm that if you send in html_notes instead of notes you will be able to use SOME html tags. The html tags that is valid is not documented, so you will have to test to find working tags.

"html_notes": "<strong>This will be bold in Asana</strong>"

I used the following with success when creating a task within a Workspace and a project. Note that this is using WebRequest in a ASP.NET WebApi (C#). But the Json string should work just fine with your project :)

IMPORTANT: Do not encode the html before POST.

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
            var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://app.asana.com/api/1.0/tasks");
            httpWebRequest.Method = "POST";
            httpWebRequest.PreAuthenticate = true;
            httpWebRequest.Headers.Add("Authorization", "Bearer <PERSONAL_TOKEN>"); 
            httpWebRequest.ContentType = "application/json";

            string json = "{\"data\": {\"workspace\": \"123456789\",\"html_notes\": \"<strong>" + question.Message + "</strong>\",\"name\": \"" + Username + "\",\"projects\": \"123456789\"}}";

            using (StreamWriter sw = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                sw.Write(json);
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                result = streamReader.ReadToEnd();
            }
0
pankaj On

A simple way using ASANA API's use this..

URL : https://app.asana.com/api/1.0/tasks 
Method : POST
HEADER : Authorization:Bearer <your token>
         Content-Type:application/json
         Accept:application/json

Body : 
{
  "data": {
    "approval_status": "pending",
    "assignee": "1111----572318",
    "assignee_status": "upcoming",
    "due_on": "2019-09-15",
    "followers": [
      "31441----023","1617----554125"
    ],
    "html_notes": "<body>Looking how can i create task under a <strong>project</strong></body>",
    "name": "Task created form Postman - 3",
    "workspace": "11288-----8660",
    "projects":["1185----23561"]
  }
}

Sample enter image description here