Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Artifactory API AQL "Displaying Specific Fields"

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

like image 401
Jag Thind Avatar asked Dec 06 '25 16:12

Jag Thind


2 Answers

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.

like image 129
Gidi.S Avatar answered Dec 11 '25 19:12

Gidi.S


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")

like image 33
Ken T Avatar answered Dec 11 '25 21:12

Ken T