What would be the correct HTTP status to return when I am performing the POST request to create a new user, but one of its parameters is incorrect - the company id I am including with the user data doesn't exist in the database.
POST data: {username: 'newuser', age: 99, company_id: 34}
the company with id 34 does not exist in the database.
I was thinking whether that could be:
- 400, kind of invalid data, but it is valid but nonexistent id
- 404 - but it is not so clear which resource does not exist
- 409, because it is kind of conflict and the user can resolve that by changing the company id
- 422?
- or 500 - because it is kind of database error while non existing id's are not allowed there