Can not set variable environment using Octopus.Client

I have a lot of variable configuration to do, and detesting mindless data entry, I decided to use the web api to automate the process.

I basically pick up an xml file, parse out the values and set them in the variables for a project. Much the same as demonstrated here :

I run into a problem when I try and set the environment though. If I have do not have dashes in the environment name, I get the following error :

An unhandled exception of type 'Octopus.Client.Exceptions.OctopusServerException' occurred in Octopus.Client.dll
Additional information: Octopus Server returned an error: The document ID My Test doesn't have a dash!

This happens regardless if I have a one word environment name, or a multiword environment name. So ‘My Test’ and ‘MyTest’ both trigger this error.

Further, if I add the dash, all the variables on the server get set, but no environment gets set. If I pass more than one environment in, all having dashes, all I see are commas in the Scope box in the UI.

Am I missing something here? Are there limitations I do not know about?

Here is the technichal stuff

Octopus Version 3.2.2
Octopus.Client Library 3.2.4

The project with the error can be found here :

The xml structure it expects looks like


And the command line for the app looks like

  -server "http://yourserverhere" 
  -key "your key here" 
  -project "your project here"
  -file "path to xml file"
  -environment "project1, project2"
  -xpath "//whatever"

Hi Steve,

Thanks for getting in touch!

The scope field expects the IDs of the environments want the variable to be scoped to, from what I can tell you’re passing in the name of the environment(s), you’d need to retrieve the environments you’re looking for from the Octopus server and then use the IDs to populate the scope field.

Hope that helps!

Thank you and kind regards,

And it works now!

Thanks for the help!


Hi Steve,

Great to hear that you got it working!

Thank you,