Artifactory Create Repository Rest API不起作用

问题描述 投票:1回答:2

我有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的消息:{“errors”:[{“status”:400,“message”:“找不到有效的存储库类型。\ n”}]}
  3. 存储库创建Json消息:{“key”:“newrepo”,“rclass:”local“,”packageType“:”docker“,”dockerApiVersion“:”V2“,”includesPattern“:”** / *“,”excludesPattern “:”“,”repoLayoutRef“:”simple-default“,”description“:”“,”checksumPolicyType“:”client-checksums“,”blackedOut“:false,”propertySets“:[”artifactory“]}

谢谢

rest api repository artifactory
2个回答
0
投票

在你的JSON中,你错过了“在rclass之后。

你写了'“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"] 
}

0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.