14

What would you use for a successful HTTP status code but wanted to indicate some warnings? In my case, I'm making an ajax endpoint where you can add a new user. We expect a first and last name, but if there isn't one, the record will still be created and no followup to correct the situation will be expected. I just want the client to know "We created the record, and hey, BTW, the first and/or last name was blank"

I found this question, but that's about actual ensuing errors, not warnings.

2

2 Answers 2

9

It seems to be an optimal way to put something like {"status":"warn","meassage":"Name field is empty"} to the response body. There is no "warning" HTTP codes. You can of course use for example 201 CREATED for clean creation and 200 OK for warnings. But that's not a good way to use them.

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

Comments

2

Don't use for this HTTP status.

Use for this body of response. For example in JSON

{warnings:true, warning:'We created the record, and hey, BTW, the first and/or last name was blank'}

Comments

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.