Hi Shannon,
Thanks for getting in touch! I’m sorry for the delay in getting back to you here. I’m wondering if you are able to use the Octopus.Client to perform your calls, or if you are required to use REST directly as in your example.
If you were to use the Octopus.Client, this version value is available under the ActionTemplate resource. An example below from my test VM.
cd 'C:\My Scripts'
Add-Type -Path 'C:\My Scripts\Octopus.Client.dll'
$apikey = 'API-KEY' # Get this from your profile
$octopusURI = 'http://OctopusServer/' # Your server address
$endpoint = New-Object Octopus.Client.OctopusServerEndpoint $octopusURI,$apikey
$repository = New-Object Octopus.Client.OctopusRepository $endpoint
$repository.ActionTemplates.FindByName("TemplateScript")
This one line to retrieve the ActionTemplate by name returned the following:
Name : TemplateScript
Description :
ActionType : Octopus.Script
Version : 1
CommunityActionTemplateId :
Properties : {[Octopus.Action.Script.ScriptSource, Octopus.Client.Model.PropertyValueResource], [Octopus.Action.Script.Syntax, Octopus.Client.Model.PropertyValueResource],
[Octopus.Action.Script.ScriptBody, Octopus.Client.Model.PropertyValueResource]}
Packages : {}
Parameters : {}
SpaceId : Spaces-1
Id : ActionTemplates-1
LastModifiedOn :
LastModifiedBy :
Links : {[Self, /api/Spaces-1/actiontemplates/ActionTemplates-1], [Usage, /api/Spaces-1/actiontemplates/ActionTemplates-1/usage], [Logo,
/api/Spaces-1/actiontemplates/ActionTemplates-1/logo?cb=2019.12.4], [ActionsUpdate, /api/Spaces-1/actiontemplates/ActionTemplates-1/actionsUpdate]...}
You can see there is a Version property in the top level and you can even append .Verion
to the initial request:
$repository.ActionTemplates.FindByName("TemplateScript").Version
This will simply return 1
for my example.
Whilst Octopus is built as an API first program, we strongly recommend using the Octopus.Client where possible as it’s been designed to make these sort of calls much easier to work with.
If you have any questions at all here, or run into any issues, please don’t hesitate to let me know.
Best regards,
Daniel