0

I'm current building a API that can return a determinated city based on it name. My code it's working, the problem that i'm facing is the correct status code to use on a request, that fulfilled itself, but doesn't has a answer, because the city wasn't found.

Which status code should i use in this case? I tried use 204 NO-CONTENT, but then the response doesn't have a body and my custom exception for city-not-found became useless.

1 Answer 1

1

The HTTP 204 No-Content code is a success status response code, indicates that a request has succeeded. In this case you can try 404 Not-Found which u can catch and use your custom exception.

Sign up to request clarification or add additional context in comments.

1 Comment

I actually did that for now. I need the response body so NO_CONTENT can't be used in this case. Marking this as answer, it resolve my problem for now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.