2016-06-24 2 views
0

Visual Studio Team Services API를 통해 첨부 파일을 보내고 작업의 첨부 파일을 볼 때까지 모든 것이 잘 보이는 것처럼 보입니다. 목.Visual Studio Team Services의 작업 항목에 이미지 첨부 (Visual Studio Online)

첨부 파일은 그림이어야하지만 흰색 십자가가있는 약간 검은 색 상자 여야합니다.

누구든지이 문제가 있었고 누구든지 내가 잘못 한 것을 알고 있습니까?

나는 이미지를 얻을

FileInfo info = new FileInfo(attachment.Path); 
    byte[] bytes = File.ReadAllBytes(info.FullName); 
    String file = Convert.ToBase64String(bytes); 

그럼 내가 API로 보내 64 기본 문자열로 변환합니다. 이것은 성공했다는 메시지를 반환합니다.

using (System.Net.Http.HttpClient client = new System.Net.Http.HttpClient()) 
      { 


       client.DefaultRequestHeaders.Authorization = 
          new AuthenticationHeaderValue("Basic", 
          Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(getConnectionDetails()))); 


       using (System.Net.Http.HttpResponseMessage response = client.PostAsync(SetURL(url), 
        new StringContent(binaryString,Encoding.UTF8,"application/json")).Result) 
       { 
        response.EnsureSuccessStatusCode(); 
        responseString = await response.Content.ReadAsStringAsync(); 
       } 
      } 

내가 뭔가 부족하다고 생각합니다.

이것은 내가 사용한 문서에 대한 링크입니다. 일

... 
string uri = "https://xxxxxx.visualstudio.com/_apis/wit/attachments?fileName=test.jpg&api-version=1.0"; 
string filepath = "C:\\images\\test.jpg"; 
FileStream files = new FileStream(filepath,FileMode.Open); 
StreamContent streamcontent = new StreamContent(files); 
... 
HttpResponseMessage response = hc.PostAsync(uri, streamcontent).Result; 
... 

답변

1

은이 방법을 사용해보십시오.
+0

감사 :

API document

관련 문제