2017-09-01 109 views
0

我可以使用PHP與Asana API創建項目/任務/附件。 有沒有辦法創建Bold for 強調任務/項目的描述? 我無法在Asana API中找到它。 有人可以指向我正確的方向嗎?如何用粗體描述創建一個任務爲asana?

+0

見與回答前面的問題:) https://stackoverflow.com/questions/43106229/can-i-send-an-html-tags-like-b-or-strong-in-a-post -request-so-that-my-text – Marius

回答

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

謝謝..! 我會試一試,讓你知道。 –

+0

這很好。 您是否可以創建新行(\ n或
)作爲筆記? –

+0

我能找到新行..! 您需要使用Literal新行發送信息。 –