Search code examples
pythonflaskflask-restful

What should be the status code if the value is not present in DB against the particular column?


I have put API which will modify user city based on user name.'api/v1/user/modify_city' . In request body i have input JSON.

{
  'name':'Jhon',
   'city': 'NY'
} 

I want to modify city to be 'NY' against 'Jhon' user name but user name jhon is not exist in DB , so in this case what should i return the status code?


Solution

  • Standard HTTP status code is 404 in this case.

    https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

    Some projects use different conventions, in which case local convention must have precedence.