• Post Reply Bookmark Topic Watch Topic
  • New Topic

Handling input parameters in REST Services  RSS feed

 
Sanju Manc
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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?

Thanks
 
Ron McLeod
Saloon Keeper
Posts: 1562
222
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sanju Manc
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Dave Tolls
Ranch Hand
Posts: 2835
30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't that just the PATCH call Ron showed?

I;m not sure I understand what the issue would be with that?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!