Pull specific fields when making API Calls

I am making API calls to retrieve all my releases for a given project
This is what I am using:
Invoke-WebRequest -UseBasicParsing -URI https://octopusserver/api/<Space_ID>/projects/<Proj_ID>/releases?apiKey=<OCTO_APIKEY>&take=100 | select -expand Content

This work fine, but the response is massive and take my software way too long to process it.
The only fields I need are Items.Id and Items.Version

How could I only pull those two fields when making my API Call ?

Hi @smartin147290,

Thanks for getting in touch! When pulling data from the API endpoints in Octopus, you will need to pull the entire object, but you can apply some filtering inf the URL to limit the results. You can then return only the information you need from those limited results. The below script is simple but will do just this.

# Define working variables
$octopusURL = "https://OctopusURL/" # Octopus URL.
$octopusAPIKey = "API-KEY" # Your Octopus API key.
$header = @{ "X-Octopus-ApiKey" = $octopusAPIKey } # Octopus API key header.
$spaceName = "default" # Space name. Use "default" if no other space exists
$projectName = "projectName" # Project name.

# Get the space ID from name.
$spaceId = (Invoke-RestMethod -Method Get -Uri "$octopusURL/api/spaces/all" -Headers $header) | Where-Object {$_.Name -eq $spaceName} | Select-Object -ExpandProperty Id

# Get the project ID from name.
$projectId = (Invoke-RestMethod -Method Get -Uri "$octopusURL/api/$spaceId/projects/all" -Headers $header) | Where-Object {$_.Name -eq $projectName} | Select-Object -ExpandProperty Id

# Get the list of all releases for the project.
$projects = (Invoke-RestMethod -Method Get -Uri "$octopusURL/api/$spaceId/projects/$projectId/releases" -Headers $header).items

# for each item in $projects, return the id and version
$projects | ForEach-Object {
    Write-Host "Release ID ="$_.Id
    Write-Host "Release Version ="$_.Version

This script will return data along the following lines:

Release ID = Releases-18368
Release Version = 0.0.3
Release ID = Releases-18367
Release Version = 0.0.2
Release ID = Releases-18355
Release Version = 0.0.1

You can modify the final command to return whatever information you need from the releases for the defined project.

If you have any further questions or thoughts at all, please don’t hesitate to let me know.

Best regards,