如何使用粗体描述在体式中创建任务?

时间:2017-09-01 06:47:49

标签: asana asana-api

我可以使用PHP的Asana API创建Project / task / attachment。 有没有办法为任务/项目的重点描述创建粗体? 我在Asana API中找不到。 有人能指出我正确的方向吗?

2 个答案:

答案 0 :(得分:2)

我可以确认,如果您发送 html_notes 而非备注,则可以使用某些html标记。没有记录有效的html标签,因此您必须进行测试才能找到工作标签。

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

在Workspace和项目中创建任务时,我成功使用了以下内容。请注意,这是在ASP.NET WebApi(C#)中使用WebRequest。但是Json字符串应该可以正常运行你的项目:)

重要提示:请勿在POST之前对html进行编码。

            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();
            }

答案 1 :(得分:0)

使用ASANA API的简单方法就是使用此方法。

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"]
  }
}

样本 enter image description here

相关问题