title: How can I get a Lambda using AWS Gateway to return HTTP error status code in C#
body: <p>I'm trying to return status error codes (ex. 500, 400, 401) through my AWS Gateway and can't seem to figure it out.</p>
  
  <p>I've seen a few examples, where they do something like:</p>
  
  <pre><code>return context.fail('Bad Request: You submitted invalid input');
  </code></pre>
  
  <p>However, there is no fail or succeed methods on the <code>ILambdaContext</code> object.</p>
  
  <p>Here's what I've got so far (non-working) </p>
  
  <p>Lambda Code:</p>
  
  <pre><code> var addressresponse = new AddressValidationResponse();
              addressresponse.Errors = new string[1];
              addressresponse.Errors[0] = "test error";
              addressresponse.Reason = "client_error";
  
   return addressresponse;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/hQulN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hQulN.png" alt="Custom Error model"></a></p>
  
  <p><a href="https://i.stack.imgur.com/IDK8B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IDK8B.png" alt="Integration Response"></a></p>
  
  <p><a href="https://i.stack.imgur.com/OT1iQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OT1iQ.png" alt="Method Response"></a></p>
  
  <p>I think I'm close, but I'm still getting a 200 back with the response of:</p>
  
  <pre><code>{
    "Reason": "client_error",
    "Errors": [
      "test error"
    ]
  }
  </code></pre>
  
  <p>What am I missing here?</p>