简体   繁体   中英

JFrog Artifactory API query for object properties does not return requested detail

I am requesting label properties for docker artifact, perhaps the url is not correct? I get response object (json) but label properties are not included. Code example:

  response = Net::HTTP.get_with_headers("http://myrepo:8081/artifactory/api/storage/dockerv2-local/anonymizer/functional/manifest.json;docker.label.com.company.info.build='*'", 
                          {'Authorization' => 'Bearer <REDACTED>'})
  if response.code.to_s == "200"
    puts ("Artifactory response "+ response.body)
    puts ("response object: "+response.inspect())
  else
    puts ("Artifactory request returned "+response.code.to_s)
  end

Connecting to artifactory
Artifactory response {
  "repo" : "dockerv2-local",
  "path" : "/anonymizer/functional/manifest.json",
  "created" : "2018-03-14T14:52:22.681-07:00",
  "createdBy" : "build",
  "lastModified" : "2018-03-15T15:52:34.225-07:00",
  "modifiedBy" : "build",
  "lastUpdated" : "2018-03-15T15:52:34.225-07:00",
  "downloadUri" : "http://myrepo:8081/artifactory/dockerv2-local/anonymizer/functional/manifest.json",
  "mimeType" : "application/json",
  "size" : "1580",
  "checksums" : {
    "sha1" : "bf2a1f85c7ab8cec14b64d172b7fdaf420804fcb",
    "md5" : "9c1bbfc77e2f44d96255f7c1f99d2e8d",
    "sha256" : "53e56b21197c57d8ea9838df7cffb3d8f33cd714998d620efd8a34ba5a7e33c0"
  },
  "originalChecksums" : {
    "sha256" : "53e56b21197c57d8ea9838df7cffb3d8f33cd714998d620efd8a34ba5a7e33c0"
  },
  "uri" : "http://myrepo:8081/artifactory/api/storage/dockerv2-local/anonymizer/functional/manifest.json"
}
response object: #<Net::HTTPOK 200 OK readbody=true>

If I understand you correctly, you want to get the properties of the manifest.json file, "docker.label.com.company.info.build" in particular.

From looking at your command:

response = Net::HTTP.get_with_headers("http://myrepo:8081/artifactory/api/storage/dockerv2-local/anonymizer/functional/manifest.json;docker.label.com.company.info.build='*'", 

It seems that you are using a semicolon to get the properties, which is not the right way. As you can see in this REST API, in order to use the get properties you should use the ampersand sign, so your command should look like:

response = Net::HTTP.get_with_headers("http://myrepo:8081/artifactory/api/storage/dockerv2-local/anonymizer/functional/manifest.json&docker.label.com.company.info.build='*'", 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM