Artifactory Create Repository Rest API不起作用

时间:2018-06-15 12:40:36

标签: rest api repository artifactory

我有Artifactory专业版许可证,如下页所示,我打电话给rest api。

https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-CreateRepository

我已经验证所有其他API(如存储库列表,帐户创建和列表)都能正常工作,但我已确认存储库创建API不能处理400个错误。

我想通过更改日志级别来查看错误,但是没有关于跟踪日志级别出现400错误的原因的信息。

以下是相关日志:

2018-06-15 10:31:34,028 [http-nio-8081-exec-15] [TRACE] (o.a.a.d.r.DockerV2AuthenticationFilter:84) - DockerV2AuthenticationFilter path: /api/repositories/newrepo

2018-06-15 10:31:34,028 [http-nio-8081-exec-15] [DEBUG] (o.a.w.s.a.AuthenticationFilterUtils:105) - Entering ArtifactorySsoAuthenticationFilter.getRemoteUserName

2018-06-15 10:31:34,028 [http-nio-8081-exec-15] [DEBUG] (o.a.w.s.AccessFilter:299) - Cached key has been found for request: '/artifactory/api/repositories/newrepo' with method: 'PUT'

2018-06-15 10:31:34,028 [http-nio-8081-exec-15] [TRACE] (o.a.s.PasswordDecryptingManager:95) - Received authentication request for org.artifactory.security.props.auth.PropsAuthenticationToken@3dc5bccf: Principal: null; Credentials: [PROTECTED]; Authenticated: false; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: {IP}; SessionId: null; Not granted any authorities

2018-06-15 10:31:34,029 [http-nio-8081-exec-15] [DEBUG] (o.j.a.c.h.AccessHttpClient:109) - Executing : GET http://localhost:8040/access/api/v1/users/?cd=apiKey_shash%3DGprGDe&exactKeyMatch=false

2018-06-15 10:31:34,035 [http-nio-8081-exec-15] [DEBUG] (o.a.w.s.AccessFilter:305) - Header authentication org.artifactory.security.props.auth.PropsAuthenticationToken@c20ca8df: Principal: admin; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: {IP}; SessionId: null; Granted Authorities: admin, user found in cache.

2018-06-15 10:31:34,035 [http-nio-8081-exec-15] [DEBUG] (o.a.w.s.RepoFilter  :100) - Entering request PUT (10.191.128.129) /api/repositories/newrepo.

2018-06-15 10:31:34,038 [http-nio-8081-exec-15] [DEBUG] (o.a.w.s.RepoFilter  :188) - Exiting request PUT (10.191.128.129) /api/repositories/newrepo

更新

  1. 我的工具版本:6.0.2
  2. 从Artifactory回复消息: { "错误" :[{ "状态" :400, "消息" :"找不到有效的存储库类型。\ n" }] }

  3. 存储库创建Json消息: { " key":" newrepo", " rclass:" local", " packageType":" docker", " dockerApiVersion":" V2", " includesPattern":" ** / *", "排除模式":"", " repoLayoutRef":" simple-default", "描述":"", " checksumPolicyType":" client-checksums", " blackedOut":false, " propertySets":[" artifactory"] }

  4. 由于

2 个答案:

答案 0 :(得分:0)

在rclass中,您的JSON中缺少“”。

您写了'“ rclass:',它应该是'” rclass“:'

修复此命令后,该命令应该可以正常工作。 祝你好运:)

curl -iuadmin:password -X PUT http://localhost:8081/artifactory/api/repositories/newrepo -H "Content-type:application/vnd.org.jfrog.artifactory.repositories.LocalRepositoryConfiguration+json" -T repo_temp.json 
HTTP/1.1 100 Continue

HTTP/1.1 200 OK
Server: Artifactory/5.11.0
X-Artifactory-Id: bea9f3f68aa06e62:4db81752:1643a9cff9e:-8000
Content-Type: text/plain
Transfer-Encoding: chunked
Date: Tue, 26 Jun 2018 06:57:24 GMT

Successfully created repository 'newrepo' 

repo_temp.json:

{ 
"key": "newrepo", 
"rclass": "local", 
"packageType": "docker", 
"dockerApiVersion": "V2", 
"includesPattern": "**/*", 
"excludesPattern": "", 
"repoLayoutRef": "simple-default", 
"description": "", 
"checksumPolicyType": "client-checksums", 
"blackedOut": false, 
"propertySets": ["artifactory"] 
}

答案 1 :(得分:0)

如果content-type标头包含字符集,Artifactory将以某种方式返回此错误,例如:Content-Type: application/json; charset=UTF-8 尝试简单地Content-Type: application/json