Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Handling input parameters in REST Services

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 3461
494
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Always look on the bright side of life. At least this ad is really tiny:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic