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?
Asked
Active
Viewed 635 times
0
-
See previous question with answer :) https://stackoverflow.com/questions/43106229/can-i-send-an-html-tags-like-b-or-strong-in-a-post-request-so-that-my-text – Marius Sep 08 '17 at 08:26
2 Answers
2
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();
}

Marius
- 199
- 9
-
-
That worked great.! Were you able to create to new line (\n or
) to notes ? – Manthan Rana Sep 15 '17 at 14:01 -
I was able to find the newline..! You need to send info with Literal new line.! – Manthan Rana Sep 16 '17 at 08:26
0
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"]
}
}

pankaj
- 1
- 17
- 36