Search code examples
restcurlartifactoryjfrog-xray

Where do I find the paths value to use with the Xray REST API - Artifact Summary call?


The XRay Rest API Artifact Summary "provides details about any artifact specified by path identifiers or checksum." The documentation ( https://www.jfrog.com/confluence/display/JFROG/Xray+REST+API#XrayRESTAPI-ArtifactSummary ) offers this template:

{
  "checksums": [
    ""
  ],
  "paths": [
    ""
  ]
}

This works if I use the SHA256 checksum of the artifact I'm interested in, however I can't determine the syntax to use with the paths tag.

From our Artifactory UI, the artifact ( a docker image's manifest.json file) has this repository Path: REPO_NAME/os/ubuntu20/ubuntu20/20.04.5/manifest.json

Using the SHA256 value for the manifest.json file in the call correctly returns the Artifact Summary json:

curl -ufoo:bar  -H "Content-Type: application/json" -d '{"checksums" : ["<SHA256_Artifact_1>"]}' -X POST https://localhost/xray/api/v1/summary/artifact

Unforutnately, using any combination of values in the 'paths' field returns a not indexed/cached in Xray.

API calls:

curl -ufoo:bar  -H "Content-Type: application/json" -d '{"paths" : ["REPO_NAME/os/ubuntu20/ubuntu20/20.04.5/manifest.json"]}' -X POST https://localhost/xray/api/v1/summary/artifact

curl -ufoo:bar  -H "Content-Type: application/json" -d '{"paths" : ["os/ubuntu20/ubuntu20/20.04.5/manifest.json"]}' -X POST https://localhost/xray/api/v1/summary/artifact

curl -ufoo:bar  -H "Content-Type: application/json" -d '{"paths" : ["os/ubuntu20/ubuntu20/20.04.5/manifest.json"], "repo" : "REPO_NAME"}' -X POST https://localhost/xray/api/v1/summary/artifact

curl -ufoo:bar  -H "Content-Type: application/json" -d '{"paths" : ["os/ubuntu20/ubuntu20/20.04.5/manifest.json"]}' -X POST https://localhost/xray/api/v1/summary/artifact?repo=REPO_NAME


Returns string:

{"artifacts":[],"errors":[{"identifier":"REPO_NAME/os/ubuntu20/ubuntu20/20.04.5/manifest.json","error":"Artifact doesn't exist or not indexed/cached in Xray"}]}

I'm looking to use the Artifact path (which is known) to request the Artifactory Summary JSON. Any suggestions on how this is to be formatted?


Solution

  • For some reason, it appears that you have to prefix your path with default. So for the example in question, the path should be default/REPO_NAME/os/ubuntu20/ubuntu20/20.04.5/manifest.json.

    The clue for me was that default kept appearing in the API docs paths, so I finally checked a summary artifact that I had retrieved using the checksum, and sure enough there it was (even though default doesn't appear in the actual path)