REST API - Should I return an error if request body has more information than needed?

Viewed 1453

My current configuration limits the number of properties and size of the request body for every endpoint. Should I return an error if request body has more information than needed?

Let's say that /authenticate endpoint requires JSON body shown below:

{
  "login": "string";
  "password": "string";
}

and the user sends a request

{
  "login": "mylogin",
  "password": "mypassword",
  "foo": "bar"
}

Should REST API return an error in this case?

2 Answers
Related