Question
Zensar Technologies Ltd
IN
Last activity: 16 Jan 2024 17:37 EST
Service REST PUT Vs POST
Hi, In Service Rest rule we have methods POST and PUT.
We can use Activity in POST method to create/insert record in database table. The same activity we can use in PUT also, so basically what is the difference between these 2 methods?
-
Reply
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Updated: 16 Jan 2024 17:37 EST
Rulesstack Private Limited
IN
Hi @AbhishekC1725,
Yes, We can use the same activity for POST and PUT methods in service-Rest. we can use when conditions in activity steps i.e. Param.pyActionType= "POST" for entering a new record, Param.pyActionType= "PUT" for updating the existing record and write logics based on methods.
Regards,
Mohd Qizer Uddin.
Accenture
IN
Hi @AbhishekC1725, In POST method, you can create a data object, for example: you can create a new employee id and create details of the new joiner. In PUT method , you can update the data object. for example: updating the details of the new joiner .
So basically POST is for creating and PUT is for updating.
For more details, check this article: https://docs-previous.pega.com/data-management-and-integration/87/service-rest-methods
Zensar Technologies Ltd
IN
@GiridharanVenkat Thanks for this, The description you gave I also followed the same, but in one discussion that Lead is asking this scenario, but in PUT method section inside activity we can write the logic for creating the new data object ? So how to justify this thing?
Accenture
IN
Hi @AbhishekC1725, In terms of PEGA, PUT and POST more are less the same but interms of HTTP. the difference is as of follows.
- Do you name the URL objects you create explicitly, or let the server decide? If you name them then use PUT. If you let the server decide then use POST.
- PUT is defined to assume idempotency, so if you PUT an object twice, it should have no additional effect. This is a nice property, so I would use PUT when possible. Just make sure that the PUT-idempotency actually is implemented correctly in the server.
- You can update or create a resource with PUT with the same object URL
- With POST you can have 2 requests coming in at the same time making modifications to a URL, and they may update different parts of the object.
Zensar Technologies Ltd
IN
@GiridharanVenkat Thanks for response.
Pegasystems Inc.
CA
@AbhishekC1725 In general, the HTTP PUT method is used to update an existing resource, while the POST method is used to create a new resource
Zensar Technologies Ltd
IN
@RameshSangili Thanks for this, The description you gave I also followed the same, but in one discussion that Lead is asking this scenario, but in PUT method section inside activity we can write the logic for creating the new data object ? So how to justify this thing?
Pegasystems Inc.
CA
I believe the interpretation is wrong PUT and POST methods - actions/protocols have to be defined by the team that is hosting the service. We have to pass in the required and optional attributes as part of the request as defined by the service.
Activity rule - Yes, we can create a new data object from the activity rule in general.
Thanks,
Zensar Technologies Ltd
IN
@RameshSangili Thanks for response. And description😊
Accepted Solution
Updated: 16 Jan 2024 17:37 EST
Rulesstack Private Limited
IN
Hi @AbhishekC1725,
Yes, We can use the same activity for POST and PUT methods in service-Rest. we can use when conditions in activity steps i.e. Param.pyActionType= "POST" for entering a new record, Param.pyActionType= "PUT" for updating the existing record and write logics based on methods.
Regards,
Mohd Qizer Uddin.
Zensar Technologies Ltd
IN
@Mohd Qizer Uddin Thanks for response. And approach
Pegasystems Inc.
GB
@AbhishekC1725 please could you mark with 'Accept Solution' the reply which resolved your question?