I'm working with REST services. I need to publish a service for updating a record in DB. There are 14 columns and the user can send any number of parameters for updating.
That means he/she can update any number of columns for a particular row.
Can you please suggest what is the best way to go with this requirement?
I can use GET request to fetch the path parameters. But the doubt is that I'm using GET for updating something on the backend , is this the right way to do?
Is there any other way to implement this using POST request?
You should be using either PATCH or PUT to make changes to an existing resource. With the APIs that I work with, we use PUT when replacing all the attributes for a particular resource, and PATCH when updating less than all the attributes (some server and client implementations do not support the PATCH method though). For example:
Get a representation of the resource before the update
Update the resource (display-name attribute only)
Get a representation of the resource after the update
Thanks for the reply. I'm afraid I may not be able to implement this way.
Because our users have DB read-access, so they have an idea of the data . But they do not have update permissions, so I'm providing REST service to update the row as per the requirements.
They want to just send the primary column value and few other column values which require update, so based on that I need to update the DB.