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 snippetExpand
cd ~/projects git clone https://github.com/SAP/cloud-s4-sdk-book.git cd cloud-s4-sdk-book git checkout mock-server
Choose File → Open Folder... and open
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.NoteSometimes the XML file indentation and consequent color coding are lost during the upload, so the file content looks like a coutinuous senquence of (black) characters. Be aware this is not impacting the xml structure, so the file will be anyway good for the exercise execution.
Run the mock server on port 8081
Edit the server.js and replace port 3000 with port 8081.
Run the following commands in the Terminal, to install the dependencies and start the mock serverCode snippetExpand
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 snippetExpand
### 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.