We've come across the following case when working on REST API.
Users have the ability to expand the product deployment by installing custom JSON configurations. These configurations tend to be lengthy and are generated automatically.
We're working on implementing an API call for installing and updating such configurations. The use-case we try to cover is when user updates an existing configuration, and wants to set the overwriting strategy. Typically we would include such option in the POST/PUT request body. But, since it might be difficult/error-prone for end users to manipulate a lengthy JSON, we want to avoid any changes to the generated JSON configuration.
Are there any best practices for such cases? We thought of passing an "overwrite" parameter in URL, which isn't quite RESTful, but is simple for end users.
overwrite
parameter does, but it sounds like it alters the meaning of the HTTP POST/PUT, which wouldn't be advisable. I don't exactly understand the requirement, but you may want to look into PATCH method as an alternative for clients that only want to set a subset of values.POST /configurations
to add a new configuration (with possibly an error if the new configuration couldn't be added) andPOST /configurations/<id>
to update an existing configuration?Are there any best practices for such cases? We thought of passing an "overwrite" parameter in URL, which isn't quite RESTful
- if your api is restful then your client won't notice. The url is not hardcoded in clients, that is the point of restfulness. The url is provided by the server and discovered by the client by using a "rel" or similar attribute for the link.