I'm designing a new web application which is powered by a REST backend and HTML+JS frontend.
There's one POST method on it to change one entity (let's call Config), that has several side effects in the state of many elements of the application. Let's suppose the POST is performed this way:
POST /api/config BODY {config: ....}
Because of this, I would like to show a preview before those changes are made, for the end user to be able to notice what's going to change.
The thing I first thought about is to make a GET endpoint for the preview, sending the body of the new state of the entity. This way:
GET /api/preview/items BODY {config: ....}
Might show the new state for the items with the new configuration.
GET /api/preview/sales BODY {config: ....}
Might show the new state for the sales with the new configuration.
It seems a good idea to use the GET verb as I'm not altering the state of the application. However, the use of a request body with GET requests seems to be discouraged.
Is there any good practice about this? Other choice might be to store the config as a draft with one method and display the results with others, but it would require an additional step and having to manage the drafts in the server:
POST /api/preview/config BODY {config: ....}
GET /api/preview/items?idPreviewConfig=1
items
orsales
? Does it affect the representation of the returned entity?items
andsales
(not the structure), depending on the config you POST.