Sending a status of "failure" doesn't seem to work.

I’m trying to set a status with the following payload:

{
  "state":"failure",
  "target_url":"<link to build>",
  "description":"The build failed!",
  "context":"CI - Unity Cloud Build"
}

but the status API always responds with 

{
  "message":"Validation Failed",
  "errors":[
    {
      "resource":"Status",
      "code":"custom",
      "field":"state",
      "message":"state is not included in the list"
    }
  ],
  "documentation_url":"https://developer.github.com/v3/repos/statuses/#create-a-status"
}

I occaisionally get this response back for the success status as well, but I’m consistently receiving it when trying to set a failure status. Are the docs at https://developer.github.com/v3/repos/statuses/#create-a-status not updated?

1 Like

Hi @codeimpossible,

To create a status, it requires a POST request, and for non-GET requests you should pass parameters in a JSON body, not in the URL.

Please see this documentation:

https://developer.github.com/v3/#parameters

Hope this helps.

I see the same failure for a valid POST request.  Our system logs show what we sent and what we received in return:

Received 422 response from GitHub:
{
    "message": "Validation Failed",
    "errors": [
        {
            "resource": "Status",
            "code": "custom",
            "field": "state",
            "message": "state is not included in the list"
        }
    ],
    "documentation_url": "https://developer.github.com/v3/repos/statuses/#create-a-status"
}
 in response to sending
{
    "state": "failed",
    "description": "Branch name is 'master' or matches regex ^ABC-[0-9]{1,4}$",
    "context": "check-branch-name",
    "target_url": ""
}

Sorry for the noise, disregard this, the state of failed should have been sent as failure.  API call works as expected.