Reputation: 7656
I'm designing a REST API using Laravel 5.1.
I'm curious is it necessary to validate query string?
https://www.example.com/users?page=1;count=20
what if user put page="abc" or count="abc"?. Should i return an error or just return empty result?
Thanks
Upvotes: 1
Views: 529
Reputation: 41878
In theory an URI is an atomic identifier, so you should return a 404 Not Found
, regardless of the wrong syntax or semantics. In practice, it's better to return a 400 Bad Request
and a detailed explanation of the error.
Upvotes: 1