This project was created following a tutorial by Somnath Paul on how to consume REST APIs within SAP Cloud Application Programming Model (CAPM) backend services. The tutorial demonstrates the process using the JSON Placeholder API, a free online REST API for testing purposes.
The project covers:
- Service Definition: Defining function imports and actions in a CAPM service file (
todo-task.cds) to interact with the REST API. - Local Binding: Demonstrating local binding of the REST API within the CAP service for simplicity, suitable for development and learning.
- Backend Logic Implementation: Creating a backend service logic file (
todo-task-service.js) to connect to the REST API and implement the logic for retrieving and creating data. - Testing: Testing the API endpoints using a dedicated test file (
test.http) and debugging the CAPM service with VS Code.
This project serves as a practical guide for developers looking to integrate REST APIs into their SAP CAPM applications. It provides a clear and concise example, ideal for learning the fundamentals of REST API consumption in CAPM.
To get started with this project, you will need:
- Node.js and npm installed.
- SAP Cloud Application Programming Model (CAPM) tools installed and configured.
- VS Code (recommended) with relevant extensions for CAPM development.
-
Clone the repository:
git clone https://github.com/marksmith-II/cap.rest.api.get
-
Navigate to the project directory:
cd <project_directory>
-
Install dependencies:
npm install
-
Start the CAPM service:
cds watch
-
You can then test the API endpoints using the
test.httpfile in VS Code or any other REST client.
- Use the
test.httpfile provided in the project to test the API endpoints. - You can also use tools like Postman or curl to test the API.
- Debug the CAPM service in VS Code by setting breakpoints in the
todo-task-service.jsfile.