2
votes

In web-API client made a get request with a parameter, to process something and get data from the file system. The parameter requested through the API a folder path. If API found that path, it is processing something on the resources inside and returning the processed content with Http-200 status code. This is perfect.

What if the folder exists and while processing some content missing in the path to process. Should API return Http-200 with empty content or Http-204 with/without response message?

1

1 Answers

1
votes

It depends on how you view the situation and how you interpret the result:

  • 200 - The request successfully executed
  • 204 - The request executed successfully but didn't produce anything to return
  • 400 - The request was not successful as the resource doesn't exist

you could use any of the above if you feel it is correct to do so, if a user tries to find an account via a GetAccount function that accepts an account number as input and that account doesn't exist I would return a 400 bad request error as the account did not exist, but I would also return an error string with something like 'unrecognised account number'