3

In our system an article(title, description) can be created, updated an drafted.

  • create - put
  • update - post
  • draft - ???

How to draft an article in REST?

leciro
  • 43
  • 6

2 Answers2

4

If your REST api uses for example JSON, you could just have a draft flag on the article that can be true or false. Or a published flag that is true or false.

Evert
  • 93,428
  • 18
  • 118
  • 189
2

As @Evert said, you can just use an attribute on the resource itself.

Or you could make the draft into a separate resource, which you can create, update and delete. When you promote the draft into an article, you could have the GET on that resource return an HTTP 301 Moved permanently.

It kind of depends on what workflow you want to support.

MvdD
  • 22,082
  • 8
  • 65
  • 93
  • In case when draft promote to article, what it will be, update? – leciro Apr 01 '18 at 06:43
  • @leciro are you asking how to promote a draft to an article? Yes, I'd imagine that would either be a PUT or POST to the resource. – MvdD Apr 01 '18 at 07:21
  • put - create a draft, post - update a draft, so how it will be to promote? to add a flag on update? – leciro Apr 01 '18 at 07:27
  • It would depend on your database representation of the resource, but a state field on your resource would be an obvious way to do this. – MvdD Apr 01 '18 at 07:30