Latest version of package

Hi again,

You helped me very much in the ticket http://help.octopusdeploy.com/discussions/questions/5598-octopus-api but I have one more question :slight_smile:

How can I get the latest version of a package (which is actually a NuGet package version because I use NuGet package version number as an Octopus Package version number) if a release hasn’t been created yet? No need in C# example, it would be OK if you show me HTTP example only, I’ll re-write it in C# by myself.

Thanks!

Hi again!

Doing a GET to this URL would get you the latest version uploaded to the built-in repository of a package with the ID TestConfig (change that part in the URL to match your package)

[YourOctopusURL]/api/packages?nuGetPackageId=TestConfig&skip=0&take=1

The response will be a JSON which looks a bit like this:

  "ItemType": "Package",
  "IsStale": false,
  "TotalResults": 14,
  "ItemsPerPage": 1,
  "Items": [
    {
      "Id": "packages-TestConfig-2.0.4",
      "NuGetPackageId": "TestConfig",
      "Title": null,
      "Summary": null,
      "NuGetFeedId": null,
      "Version": "2.0.4",
      "Description": "Package description",
      "Published": "15 September 2015 15:01",
      "ReleaseNotes": null,
      "PackageSizeBytes": 4132,
      "Links": {
        "Self": "/api/packages/packages-TestConfig-2.0.4",
        "AllVersions": "/api/packages?nuGetPackageId=TestConfig",
        "Feed": "/api/feeds/feeds-builtin",
        "Raw": "/api/packages/packages-TestConfig-2.0.4/raw"
      }
    }
  ]

Hope that helps!

Dalmiro

Thank you for the feedback! I tried something like that, it looks like my problem is appeared as I use my own NuGet Package feed (not Built-in). Can I get a package version from it with Octopus API?

OK, I tried to browse to my feed. Link http://localhost:81/Api/feeds/feeds-myfeed , here is a result:

{
  "Id": "feeds-myfeed",
  "Name": "MyFeed",
  "FeedUri": "C:\\Packages\\",
  "Username": null,
  "Password": null,
  "Links": {
    "Self": "/api/feeds/feeds-myfeed",
    "Packages": "/api/feeds/feeds-myfeed/packages",
    "SearchTemplate": "/api/feeds/feeds-myfeed/packages{?packageId,partialMatch,includeMultipleVersions,includeNotes,includePreRelease,take}",
    "VersionsTemplate": "/api/feeds/feeds-myfeed/packages{?packageIds}",
    "NotesTemplate": "/api/feeds/feeds-myfeed/packages/notes{?packageId,version}"
  }
}

It seems that I should browse to something like it to see my packages from feeds-MyFeed: http://localhost:81/api/feeds/feeds-myfeed/packages . But the result is:

[]

Please note that I have no problem in deployments by UI-interface, I mean it seems that integration is OK. I create a new NuGet Package, it saves in my feed - and I can see a new version in the Releases-Create New Release UI.

What am I doing wrong?

OK, I know the version of my NuGet Package so actually it’s not essential for me to get it from Octopus API. But I can’t understand why I can’t see it with URL http://localhost:81/api/feeds/feeds-myfeed/packages

Hi,

The problem is that Octopus doesn’t cache the packages information from third party feeds, It only keeps track of the built-in feed. When using 3rd party feeds, Octopus queries it in real time at the moment of the deployment, reason why when you create a new release you can see the latest version on the UI.

Hope that helps clearing this up

Dalmiro

Dalmiro,

Thank you again for your high-quality consultations!