I saw the following Action section inside of Apiary blueprint examples. I want to response with HTTP status 404 when the user passes a wrong parameter. for example when the user passes /questions/xyz instead of /questions/1. As you can see we defined that the parameter after /questions must be a number but when I passed xyz itstead of a number it answer with a same object.
## Questions [/questions/{question_id}]
An Questions object has the following attributes:
+ question - We can put some description for each attribute here.
+ published_at - An ISO8601 date when the question was published.
+ url (string)
+ choices - An array of Choice objects.
+ Parameters
+ question_id: `1` (number, required) - ID of the Questions in form of an integer
### View an Questions Detail [GET]
+ Response 200 (application/json)
{
"question": "Favourite programming language?",
"published_at": "2014-11-11T08:40:51.620Z",
"url": "/questions/1",
"choices": [
{ <!-- First Object -->
"choice": "Swift",
"url": "/questions/1/choices/1",
"votes": 2048
}
]
}
+ Response 404 (text/plain)
There is no such a message for the passed id. For example if you pass 'xyz' we expect to show this message.
Please write me complete code. Thanks in advance.
I am sorry but unfortunately Apiary doesn't yet support conditional responses based on the body and parameters that are passed in a request.