C# Cycle Lights

What am I missing, trying to cycle the lights in C#? It’s a POST method.

Here is the JSON body that I’m sending.

{
  "defaults": {
    "duration": 2,
    "power": "on",
    "saturation": 0
  },
  "states": [
    {
      "brightness": 1,
      "power": "on"
    },
    {
      "brightness": 0.5,
      "power": "on"
    },
    {
      "brightness": 0.1,
      "power": "on"
    }
  ]
}

And the C# code.

WebClient client = new WebClient();
client.Headers.Add("authorization", string.Format("Bearer {0}", TOKEN));
string url = string.Format("https://api.lifx.com/v1/lights/id:{0}/cycle", light.id);
client.UploadData(url, "POST", System.Text.Encoding.ASCII.GetBytes(body));

I’m getting a 400 error back.

The remote server returned an error: (400) Bad Request.

I checked in the example project here:

I solved my issue. I had extra nulls at the end of my json data. Cycle works as expected.

Updated the source.