Reputation: 18046
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.
Upvotes: 14
Views: 8430
Reputation: 1196
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.
Upvotes: 9
Reputation: 2719
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'}
Upvotes: 2