通过Asana API将附件上载到任务时,请确保将请求的内容类型设置为“multipart / form-data”,包括实际文件的数据,而不是字节流。
https://asana.com/developers/api-reference/attachments
这是C#中的一个例子
using System; using System.Net; using System.Text; class AttachFile { static void Main () { Uri uri = new Uri("https://app.asana.com/api/1.0/tasks/<TASK_ID>/attachments"); string filePath = @"<FILE_PATH>"; WebClient client = new WebClient(); string authInfo = "<API_KEY>" + ":"; authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo)); client.Headers["Authorization"] = "Basic " + authInfo; client.UploadFile(uri, filePath); } }