How can i do to send a Bad Request from REST service RRS feed

  • Question

  • I have this:

    User fill a form. If he leave serial number blank each product then the system fires a Bad Request. I'm using a rest service and i don't know how can i do this? How can i return a code 400 to client via rest/json? How? User must receive code 400

    • Edited by pnet Friday, March 16, 2018 12:56 PM
    • Moved by CoolDadTx Friday, March 16, 2018 1:46 PM ASP.NET related
    Friday, March 16, 2018 12:52 PM

All replies

  • It depends on your used framework.

    In WebApi2 you just set the HTTP return code

    return new StatusCodeResult(HttpStatusCode.BadRequest, this);

    Friday, March 16, 2018 1:03 PM
  • Stefan Hoffman, please. I have this doubt. I need to return a Bad Request into my Action and in this Bad Request, i need to send some information.

    [HttpPost, Route("ProcessOrderEG/{ordIdEg}/{actionType}"), AspectLogService]
    public ActionResult ProcessEncomendaEG(int ordIdEg, int actionType)

           //Here how to return a bad request and my object


    Friday, March 16, 2018 1:38 PM
  • Please post questions related to web development in the ASP.NET forums.

    Michael Taylor http://www.michaeltaylorp3.net

    Friday, March 16, 2018 1:46 PM