returning status 400 with error messages

18 views
Skip to first unread message

Phil Cruz

unread,
Apr 5, 2012, 1:11:32 PM4/5/12
to cfr...@googlegroups.com
I'm using taffy and I have an api call where if a required parameter is not provided I want to return an error message with a 400 status code. i.e. 

if (not len(trim(arguments.serialNumber)) )
{
     result["errorMessage"] = "Serial number was not provided";
     return representationOf(result).withStatus(400);
}

The problem is in IIS7 I have custom error pages enabled so that I can display a custom 404 pages. Apparently this is interfering with the 400 error. When the API call is made and a 400 is returned, the response simply contains "bad request". If I disable custom errors 


How can I set this up so both work?

-Phil

Phil Cruz

unread,
Apr 5, 2012, 1:22:44 PM4/5/12
to cfr...@googlegroups.com
Of course, right after I post this I find the solution


so in web.config I have

<httpErrors errorMode="Custom" existingResponse="PassThrough">
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" prefixLanguageFilePath="" path="/apps/index.cfm?action=error.404" responseMode="ExecuteURL" />
</httpErrors>

-Phil
Reply all
Reply to author
Forward
0 new messages