curlazure-devops-rest-apiazure-artifactsartifactory-query-lang

How to get the ADO artifacts API information with curl command and a timestamp?


As you known,we can get all package information list in one feedID.

https://learn.microsoft.com/en-us/rest/api/azure/devops/artifacts/artifact-details/get-packages?view=azure-devops-rest-7.1

command: GET https://feeds.dev.azure.com/{organization}/{project}/_apis/packaging/Feeds/{feedId}/packages?api-version=7.1-preview.1

I want to get some special package which meet some time conditions. Such as after 2022-10-01 13:00:00.

            pkgInfo=$(curl --request GET ${UriFeedPackages} \
                         -u :$ado_PAT \
                        --header 'Content-Type: application/json' -s -k |
                        jq  -r '.value[]|"\(.name),\(.id),\(.protocolType)"')

Use this command,i can get all pkgName,pkgId,and protocol.

According https://curl.se/docs/manual.html,I try to use -z/--time-cond,but it's not a good output.

       curl -z "Mon Oct 10 14:05:48 2022" --request GET ${UriFeedPackages} \
                         -u :$ado_PAT \
                        --header 'Content-Type: application/json' -s -k |
                        jq  -r '.value[]|"\(.name),\(.id),\(.protocolType)"'

And one package information format. Please note publishDate key:

  {
      "id": "1487139d-2f3a-4b25-b80f-22de8943c8af",
      "normalizedName": "xunit.extensibility.execution",
      "name": "xunit.extensibility.execution",
      "protocolType": "NuGet",
      "url": "https://feeds.dev.azure.com/{organization}/_apis/Packaging/Feeds/10360244-4d69-4d0f-a56d-d986aa911b09/Packages/1487139d-2f3a-4b25-b80f-22de8943c8af",
      "versions": [
        {
          "id": "c6105649-e7a2-4f91-a736-224d2ae5ad8a",
          "normalizedVersion": "2.4.2",
          "version": "2.4.2",
          "isLatest": true,
          "isListed": true,
          "storageId": "275C830AD4B112D0632A326175042E87E79202F370E62891AFA11818CA50D0A800",
          "views": [
            {
              "id": "1c5fa6b5-8d87-402b-881d-67eb95ba800d",
              "name": "Local",
              "url": null,
              "type": "implicit"
            }
          ],
          "publishDate": "2022-08-25T12:00:51.971141Z",
          "directUpstreamSourceId": "5aa8e74a-1aa5-4f0e-85c1-d0432a00af35"
        }
      ],
      "_links": {
        "self": {
          "href": "https://feeds.dev.azure.com/{organization}/_apis/Packaging/Feeds/10360244-4d69-4d0f-a56d-d986aa911b09/Packages/1487139d-2f3a-4b25-b80f-22de8943c8af"
        },
        "feed": {
          "href": "https://feeds.dev.azure.com/{organization}/_apis/Packaging/Feeds/10360244-4d69-4d0f-a56d-d986aa911b09"
        },
        "versions": {
          "href": "https://feeds.dev.azure.com/{organization}/_apis/Packaging/Feeds/10360244-4d69-4d0f-a56d-d986aa911b09/Packages/1487139d-2f3a-4b25-b80f-22de8943c8af/Versions"
        }
      }

I am a newbie, still figuring out the stage.

Thanks for your help.


Solution

  • We (Azure Artifacts) do not support querying that API by date.

    Also, the If-Modified-Since header (curl -z) is used to avoid downloading a resource if it has not changed since it was cached, not to provide a date query over the underlying data.