2017-09-19 73 views
0

您好我想與Artifactory的JFROG API來創建庫,但我得到了與APIJFROG版本庫的創建與阿比

406錯誤代碼,我可以運行在與選定的應用/ JSON的MIME類型郵遞員JSON請求

但我無法運行我的C#代碼。我應該如何在我的.net代碼中使用jfrog artifactory api?

{ 「鍵」: 「ArtifactRepoGroup3」, 「rclass」: 「虛擬」, 「packageType」: 「的NuGet」, 「描述」: 「這回購通過創建」}

使用(HttpClient的客戶端= new HttpClient()) client.BaseAddress = new Uri(BaseAddress); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(「application/json」));

............

HttpResponseMessage響應= client.PutAsJsonAsync(puturi, 值)。結果; }

回答

0

我不能運行PutAsJsonAsync方法與非標準應用程序/ JSON的,但我能做到這一點使用的StringContent和嵌入式jfrog特定的MIME類型到我的內容

  VirtualRepository repository = new VirtualRepository(); 
     repository.key = "ArtifactRepoGroup1"; 
     repository.packageType = "nuget"; 
     repository.rclass = "virtual"; 
     repository.description = "This repo created by "; 

     var content = JsonConvert.SerializeObject(repository); 

     var conent = new StringContent(content, Encoding.UTF8, 
          "application/vnd.org.jfrog.artifactory.repositories.VirtualRepositoryConfiguration+json"); 

....

  var response = client.PutAsync(uri, conent).Result; 
      string b = response.Content.ReadAsStringAsync().Result;