What response (code + content) should I return when my JsonAPI is requested to perform some operation that has already been done or does not make sense ?
Example : suppose I want to request an article publication. The article draft is updated through a specific endpoint (irrelevant here), and there is a specific endpoint one for publication (whose response we are interested in)
4 different scenarii, I need to figure out what type of response to send each time :
Publication had never been requested, and the article has all publication mandatory information, it makes sense to request publication so I'm returning a 202 accepted response with the article resource including the "publication requested at" attribute
A successful publication publication request was already sent/acknowledged, and no one had time to review it in between. What should I return ?
A previous publication request was reviewed by someone and accepted (the article is now published). The API receives once more a publication request to this article that was already published, it doesn't make sense, what should I return ?
The article does not have all mandatory information filled and someones make a publication request. I must inform the user his request was not granted because of errors. I was thinking for this one I could return the list of validation errors. Sounds fair ?