Skip to Content
Technical Articles
Author's profile photo Saranya Sampath

CRUD operations in Cloud Application Programming model

In this blog post will see how to do CRUD operations after defining service in CAPM

Please follow steps given in the below link to create database with sample entities and sample data till step “Querying thru OData out-of-box”

Now go to menu -> select New Terminal -> and run the command

cds run

Will get below screen in browser

Now preview Authors entity by clicking on Authors link. Will get below data


Go to project root folder and create new folder called “tests”. We can create http file in root folder as well. If we are having multiple entities, it’s easy to keep it in common folder and separate .http file for each entity for easy access.

Create new file ‘authors.http’ under tests folder .

Now in authors.http type GET. we can find auto suggestions for operations and services as well. I am selecting authors


Click on Send Request to test GET. Other Pane will be opened  and response is displayed.

Successfully tested READ.

Comments can be added  using ### in http file.



It’s time to add another author to this service. Type POST and select Authors again. Provide content-type as ‘application/json’. Entity has two properties ID, Name.

Will create sample payload with those properties. Click send request to post the data.

Post response is displayed in right pane. Response is  ‘201 Created’ new author ‘Robert’ added into entity. We can check the same from browser by refreshing




Let’s update authors name. Type PATCH and service name then author ID here it’s 121 and payload which has changes to be updated. Will update name from Robert to Robert Pattinson.

Click Send Request to see response

Same updates reflect in browser data also.



In the http file type DELETE and choose service from autosuggestion. We are going to delete author whose ID is 121

So the http file will be like this


Click on Send Request to execute delete. Content was removed. If we check authors again, will reflect old data .

We have learned how to  execute create , read ,update ,delete operations  in  CAP project locally in business application studio.

Happy learning.


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Fedor Shestov
      Fedor Shestov

      Great article! How to send a few records in the payload?

      Author's profile photo Jin Wei Min
      Jin Wei Min

      Thanks Saranya for the sharing, I try to deploy this into Cloud Foundry, but not succeeded.

      Below is the steps I have done:

      $npm i passport
      $npm i @sap/xssec
      $npm install -g mbt
      $cds add mta
      $mbt build
      $cf deploy mta_archives/<buildmta>.mtar


      The deployment is not succeeded. Below is the error message(I follow the tutorial and use the MyCDSProject as my project name):

      Error starting application "MyCDSProject-srv": Some instances have crashed.

      Check the logs of your application for more information.

      I use below command to download the log:

      $cf dmol -i 212b6a9a-67e1-11ee-a2b4-eeee0a9ed8a1


      In the "MyCDSProject-srv.log" file I found below error message:

      Error: Cannot find module '@sap/xssec'. Make sure to install it with 'npm i @sap/xssec'
      But I have already run "npm i @sap/xssec" before deployment.
      Do you have any clue for my deployment issue?



      Author's profile photo Ayush Pattnaik
      Ayush Pattnaik

      Good beginner's article