2
votes

According to below link, Artifactory AQL allows "Displaying of specific fields" via REST API by returning only fields of interest. https://www.jfrog.com/confluence/display/RTF/Artifactory+Query+Language#ArtifactoryQueryLanguage-DisplayingSpecificFields

It doesn't work if I provide a list of fields, see below

Not Work - Bad request (400)

items.find(...).include("name", "repo")

Works

items.find(...).include("*")

Can anyone advise

Thanks, Jag

2
What I had to do was make another request to get Item properties using jfrog.com/confluence/display/RTF/…Jag Thind

2 Answers

10
votes

I suspect that the problem is related to encoding during the REST call, therefore I suggest to upload the query as a file Here is a working example:

Save the following query to file, lets call it aql.query

items.find     
(                
    {
        "repo": {"$match":"*"}                
    }
)
.include("name","repo")

Run the following curl command from the same directory that contains the aql.query file and don't forget to replace the templates in the command with your user name, password, host and port.

curl -X POST -uuser:password 'http://host:port/artifactory/api/search/aql' -Taql.query

In the result you will get:

    {
        "results" : 
            [ 
                {
                    "repo" : "ext-snapshot-local",
                    "name" : "maven-metadata.xml"
                },{
                    "repo" : "ext-snapshot-local",
                    "name" : "multi-3.0.0-20150705.195404-1.pom"
                },{
                .
                .
                .
                }
            ],
        "range" : 
            {
                "start_pos" : 0,
                "end_pos" : 46,
                "total" : 46
            }
    }

As you can see that the result contains only the "item repo" and the "item name" fields.

3
votes

Had the same issue. Spent quite a bit of time trying to figure this out. Couldn't find an answer online.

With a bad request(400), I printed the response text: "For permissions reasons AQL demands the following fields: repo, path and name."

This solution worked for me - at a minimum: have repo, path, name. ie... items.find(...).include("name", "repo", "path", "created_by")