您好我想用Artifactory JFROG Api创建Repository,但是我用api获得了406错误代码
我可以使用选定的application / json mime类型
在postman上运行此json请求但我无法使用我的c#代码。我应该在.net代码中使用jfrog artifactory api做什么?
{"键":" ArtifactRepoGroup3"" rclass":"虚拟"" packageType":& #34; nuget","说明":"此回购由"}
创建使用(HttpClient客户端=新的HttpClient()) { client.BaseAddress = new Uri(BaseAddress); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(" application / json"));
............
HttpResponseMessage response = client.PutAsJsonAsync(puturi, 值)。结果; }
答案 0 :(得分:0)
我无法使用标准的应用程序/ json运行PutAsJsonAsync方法,但我可以使用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;