我正在尝试将人工查询作为主体发送到 POST 方法。我总是得到 400 的响应(这是一个错误的请求)。这是我的代码。我在这里做错了什么。查询看起来很好它可以使用curl 也可以使用Groovy。
host = http://artifactory.com/artifactory
build_url = '%s/api/search/aql' % (host)
payload='{items.find({"repo":"lib","type":"file","path":"builds"}).include("*"}'
response = requests.post(build_url,data=payload,auth=(user:pwd))
print response
输出: 响应 [400]
我使用的是 Python 2.7,这里是 REST API 详细信息
Artifactory Query Language (AQL) REST API
Since: 3.5.0
Security: Requires an authenticated user
Usage: POST /api/search/aql
Consumes: text/plain
--提前致谢
最佳答案
我认为您只是在 include("*"
之后缺少一个括号。试试这个:
payload='{items.find({"repo":"lib","type":"file","path":"builds"}).include("*")}'
编辑:根据讨论,问题是缺少身份验证。
关于python - 如何在 Python 中的 POST 请求中将查询作为正文发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34365607/