Update Variables during Deployment over REST API

Hi,

I’m trying to use the REST API to create a new release for a test project and then deploy that release with updated variables.

I found this topic from last year which is the same thing I’m doing. I tried executing the deployment API call with the payload suggested by @nick , but the variables for the the deployment are the same value as the release. I don’t get an error code, but the json preview in developer tools shows FormValues: {} and the FormValues entry isn’t updated.

Here’s my payload and API call code. I’m using Python.

data = """{
    "ReleaseId": "Releases-12345",
    "EnvironmentId": "Environments-1",
    "TenantId": null,
    "SkipActions": [],
    "QueueTime": null,
    "QueueTimeExpiry": null,
    "FormValues": {
        "8cbf56a9-08df-0c12-7f35-b24fd190297e": "NewValue",
        "a2f556f0-4cf1-028f-0213-1888743b56d6": "9"
    },
    "ForcePackageDownload": false,
    "UseGuidedFailure": false,
    "SpecificMachineIds": [],
    "ExcludedMachineIds": [],
    "ForcePackageRedeployment": false
}"""

response = requests.post(url, headers=headers, data=data)

Could someone help me figure out why this isn’t working as expected? I’ve tried changing some of the other variables, such as “ForcePackageRedeployment” and those are passed through correctly.

Thanks!

Hey Will. I wrote that question you’re referencing. If I recall, it came down to how the variables were defined in Octopus Deploy. When you define the variables in the OD project, there is (or, at least there was when I was doing this) a tickbox which says something like “Prompt for Value”. When this tickbox was not ticked, I had issues where my script couldn’t send in values. When the tickbox was ticked, my script would work as I expected, and the values provided from the script were available in the OD job.

I hope this makes sense. If your variables are already defined with the Prompt for Value enabled, then you’re seeing something different from what I recall.

Good luck,

Ed

1 Like

Thanks @Ed_Hillmann ! Way to follow through! Your explanation fits perfectly with my experience - and explains a case where I did get the updated variables working in a different project. I found the tickbox in the ‘Open Editor’ pop-up.

I see that this info was in your previous post at the bottom - I just didn’t filter it out before. :slight_smile:

Hi Will,

Thanks for getting in touch! And a big thanks to Ed for sharing your insight and nailing it on the head with this one. :slight_smile:

Please don’t hesitate to reach out if you have any questions or concerns in the future!

Best regards,

Kenny

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.