如何通过REST API执行AQL查询查找Artifactory特定属性值的制品
How to Run Your AQL Query via Artifactory REST API
Got it, let's break down exactly how to execute that AQL search using Artifactory's REST API. It's a simple POST request once you have the right pieces in place.
Key Details First
- Endpoint: You'll use the
api/search/aqlendpoint (append this to your Artifactory base URL, e.g.,https://your-artifactory-url.com/artifactory/api/search/aql) - Request Method:
POST(AQL queries are always sent as POST requests) - Authentication: Artifactory requires valid credentials—use your username + password, or username + API key (API keys are more secure for automation)
Example with curl (Most Common for Automation)
Here's a ready-to-use curl command you can adapt:
curl -u your-username:your-password-or-api-key -X POST "https://your-artifactory-instance.com/artifactory/api/search/aql" -d 'items.find({"@some_property" : {"$eq" : "some_value"}})'
A quick breakdown of the parts:
-u: Handles basic authentication—replace the placeholder with your actual credentials-X POST: Explicitly sets the request method to POST-d: Passes your AQL query as the request body. Wrap the query in single quotes to avoid shell escaping issues on most systems.
Example with Postman (For Testing/Manual Queries)
If you prefer a GUI tool:
- Open Postman and create a new
POSTrequest - Enter your full Artifactory AQL endpoint URL (e.g.,
https://your-artifactory-url.com/artifactory/api/search/aql) - Go to the Authorization tab, select
Basic Auth, and input your Artifactory username and password/api key - Switch to the Body tab, select
raw, set the format dropdown toText, then paste your AQL query:items.find({"@some_property" : {"$eq" : "some_value"}}) - Click Send—you'll get a JSON response with all artifacts that match your property filter.
What to Expect in the Response
The response will be a JSON object with a results array containing all matching items. Each item includes details like path, name, repo, properties, and more.
内容的提问来源于stack exchange,提问作者yiaca
相关产品推荐
相关产品推荐

