In this exercise, you will learn how to set up a Mock Server for Business Partner API of SAP S/4HANA Cloud for testing purposes.
For the complete execution of current exercise, you must execute the following activities first:
- Execute the following exercises:
- Creating your Pay-As-You-Go Account in SAP BTP
Clone the Mock Server repository and checkout the branch mock-server in SAP Business Application Studio
Open SAP Business Application Studio.
Run the following commands in the terminalCode snippetCopy code
cd ~/projects git clone https://github.com/SAP/cloud-s4-sdk-book.git cd cloud-s4-sdk-book git checkout mock-server
Copy the EDMX document of business partner into the business-partner folder
Browse to the SAP API Business Hub in a separate tab, then login.
Click on API Specification button and click on the download EDMX button. This will download the API_BUSINESS_PARTNER.edmx file
Copy the API_BUSINESS_PARTNER.edmx file into the business-partner folder.NoteOnce the file is copied you may have issues to properly display the contained text with proper colored syntax highlighting. In this case, to fix the file, right click on the file text and choose Format Document.
Run the mock server on port 8081
Edit the server.js and replace port 3000 with port 8081.
Run the following command to install the dependencies and start the mock serverCode snippetCopy code
npm install npm run start
Test the mock server by issuing a GET request to A_BusinessPartner entity
Create a file requests.http in the root directory
Add the following content to the fileCode snippetCopy code
### GET Business Partners GET http://localhost:8081/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner?$format=json
Click on Send Request in the requests.http file to submit the GET request
Check the response.