Install SAP Mobile Services Client on your Android device or iOS
Android
iOS
(If you are connecting to AliCloud accounts, you will need to brand your custom MDK client by allowing custom domains.)
Steps
Intro
You may clone an existing metadata project from the MDK Tutorial GitHub repository and start directly with step 15 in this tutorial but make sure you complete step 2&3.
Mobile development kit allows you to consume REST APIs. You need to first define REST endpoint as a destination and then easily bind a RestServiceTarget to an MDK control e.g., ObjectTable, ContactCell, ObjectCollection etc. This assumes the REST service returns JSON similar to how OData requests are returned.
A publicly available Petstore API from swagger.io is used as an example in this tutorial.
Petstore App Final Result Overview
Step 1Understand the Petstore API to retrieve data
what is the Request URL to retrieve pet information
what is header parameter to be passed in GET call
what is the response code
how the response body looks like
Step 2Create a New Project Using SAP Build
+
This step includes creating a mobile project in SAP Build Lobby.
In the SAP Build Lobby, click Create > Create to start the creation process.
SAP Build Lobby Create Project Button
Click the Application tile and choose Next.
Application Tile Selection
Select the Mobile category and choose Next.
Mobile Category Selection
Select the Mobile Application to develop your mobile project in SAP Business Application Studio and choose Next.
Mobile Application Option Selected
Enter the project name mdk_petstore (used for this tutorial) , add a description (optional), and click Review.
Project Name And Description Entry
SAP Build recommends the dev space it deems most suitable, and it will automatically create a new one for you if you don’t already have one. If you have other dev spaces of the Mobile Application type, you can select between them. If you want to create a different dev space, go to the Dev Space Manager. See Working in the Dev Space Manager.
Review the inputs under the Summary tab. If everything looks correct, click Create to proceed with creating your project.
Project Summary Review Screen
Your project is being created in the Project table of the lobby. The creation of the project may take a few moments. After the project has been created successfully, click the project to open it.
Project Created In Build Lobby Table
The project opens in SAP Business Application Studio.
SAP BAS Workspace Opened
When you open the SAP Business Application Studio for the first time, a consent window may appear asking for permission to track your usage. Please review and provide your consent accordingly before proceeding.SAP BAS Usage Tracking Consent Dialog
Step 3Configure the Project Using Storyboard
+
The Storyboard provides a graphical view of the application’s runtime resources, external resources, UI of the application, and the connections between them. This allows for a quick understanding of the application’s structure and components.
Runtime Resources: In the Runtime Resources section, you can see the mobile services application and mobile destination used in the project, with a dotted-line connected to the External Resources.
External Resources: In the External Resources section, you can see the external services used in the project, with a dotted-line connection to the Runtime Resource or the UI app.
UI Application: In the UI Applications section, you can see the mobile applications.
Click on the + button in the Runtime Resources column to add a mobile services app to your project.
Storyboard Runtime Resources Add Button
This screen will only show up when your CF login session has expired. Use either Credentials OR SSO Passcode option for authentication. After successful signed in to Cloud Foundry, select your Cloud Foundry Organization and Space where you have set up the initial configuration for your MDK app and click Apply.
CF Login Credentials Dialog
Click on the + button to add a new mobile services app configuration.
Add New Mobile Services App Button
In the Basic Information step, provide the required information and click Next.
Field
Value
Application Name
SAP MDK REST API
Application ID
myapp.mdk.restapi
Security Settings
Leave the default value as XSUAA
Mobile Services App Basic Information Form
In the Destinations step, provide the required information and click Create App.
Field
Value
Destination Name
swagger_petstore
Destination Type
Internet Destination
URL
https://petstore.swagger.io/v2
SSO Mechanism
No Authentication
Mobile Services Destination Configuration Form
Mobile Services App may take 2-3 minutes in creating the required configuration. You will notice the app state as Creating.
Mobile Services App In Creating State
Once the app is in Created state, click Add App to Project.
Mobile Services App Created State
You can access the mobile services admin UI by clicking on the Mobile Services option on the right hand side.
In the storyboard window, the app will be added under the Runtime Resources column.
Storyboard App Added To Runtime Resources
Click the + button in the UI application column header to add mobile UI for your project.
Storyboard UI Application Add Button
In the Basic Information step, select No for the Enable Auto-Deployment to Mobile Services After Project Creation property, and click Finish. You will modify the generated project in next step and will deploy it later.
Auto-Deployment To Mobile Services Disabled
After clicking Finish, the storyboard is updated displaying the UI component. The MDK project is generated in the project explorer based on your selections.
Storyboard Updated With UI Component
Step 4Create a new MDK Service file
+
Right-click the Services folder | MDK: New Service.
Services Folder MDK New Service Menu
Provide the below information and click Finish.
Field
Value
Name
petstore
Data Source
Select Mobile Services from the dropdown. You will be asked to select the Mobile services landscape where you have configured the MDK app
Destination
Select swagger_petstore from the dropdown
Path Suffix
Leave it as it is
Language URL Param
Leave it as it is
REST Service
choose this option
New MDK Service Configuration Form
.service and .xml (empty file) have been created under the Services folder.
Services Folder With New Service Files
Step 5Display Pets list in MDK page
+
You will add an Object Table control item on Main.page to display the list of Pets.
In the Layout Editor, expand the Controls | Data Bound Container group, drag and drop the Object Table control onto the Main.page area.
Object Table Drag Drop Onto Main Page
Provide the required information for Target section:
Field
Value
Target
Select REST Service Target from the dropdown
Service
Select petstore.service from the dropdown
Path
Enter /pet/findByStatus?status=available
Object Table REST Service Target Configuration
You can find more details on Target in documentation.
Method GET is pre-selected for binding the ObjectTable control to a RestServiceTarget.
Under Appearance, provide below information:
Property
Value
Description
leave it empty
Footnote
leave it empty
PreserveIconStackSpacing
Select false from the dropdown
ProgessIndicator
leave it empty
Status
{status}
Subhead
Pet Name: {name}
Substatus
leave it empty
Tags
Click the item0 and click the trash icon to delete the default item
Title
Pet ID: {id}
Object Table Appearance Properties Configuration
In the Avatar Grid section of the Properties pane, remove the default Avatar. First, click on the item0, a trash icon appears. Click on the trash icon to delete the default item.
Avatar Grid Default Item Deletion
In the Avatar Stack section of the Property pane, remove the default Avatar. First, click on the item0, a trash icon appears. Click on the trash icon to delete the default item.
Avatar Stack Default Item Deletion
If you see any error in Main.page (code editor), ignore it as MDK editor currently can’t validate such REST Service endpoint properties.
Step 6Deploy the Project
+
So far, you have learned how to build an MDK application in the SAP Business Application Studio editor. Now, you will Deploy the Project definitions to Mobile Services to use in the Mobile client.
Click the Deploy option in the editor’s header area, and then choose the deployment target as Mobile Services .
Deploy To Mobile Services Option Selected
Select deploy target as Mobile Services.
Mobile Services Deploy Target Selection
If you want to enable source for debugging the deployed bundle, then choose Yes.
Debug Source Enablement Prompt
You should see Deploy to Mobile Services successfully! message.
Successful Deployment To Mobile Services
Step 7Display the QR code for onboarding the Mobile app
+
SAP Business Application Studio includes a feature that displays a QR code for onboarding in the mobile client. To view the onboarding QR code, click the Application QR Code icon in the editor’s header area.
Application QR Code Icon In BAS Header
The On-boarding QR code is now displayed.
Onboarding QR Code Displayed
Leave the Onboarding dialog box open for the next step.
Step 8Run the Project
+
Ensure that you choose the correct device platform tab above. Once you have scanned and onboarded using the onboarding URL, it will be remembered. If you log out and onboard again, you will be prompted to either continue using the current application or scan a new QR code.
Follow these steps to successfully on-board the MDK client on your Android device.
After accepting the app update, you will see the Pets list on the Main page.
Pets List On Android Main Page
Ensure that you choose the correct device platform tab above. Once you have scanned and onboarded using the onboarding URL, it will be remembered. If you log out and onboard again, you will be prompted to either continue using the current application or scan a new QR code.
Follow these steps to successfully on-board the MDK client on your iOS device.
After accepting the app update, you will see the Pets list on the Main page.
Pets List On iOS Main Page
Congratulations, you have learned how to consume a REST API in MDK app to display Pets list.
Next, you will learn how to create a new pet record.
Step 9Understand the Petstore API to create new record
There is payload example to be passed for adding a new pet.
For testing, use below payload.
JSON
{"name":"pet-test","status":"available"}
Click Execute to get the response.
Swagger Petstore POST Pet Execute Response
By looking at results, you now have understood
what is the Request URL & body to create a new pet record
what are header parameters to be passed in POST call
what is the response code
how the response body looks like
With above details, you will now create a new MDK rule to create a new Pet record.
Step 10Create new page for new pet record
+
In this step, you will create a Section page with a Form Cell Section to contain the Form Cell controls. You will add the fields that will be editable by the end-user.
Right-click the Pages folder | MDK: New Page | Section | Next.
Pages Folder New Section Page Menu
In the Base Information step, enter the Page Name as Pet_Create and click Finish.
New Page Named Pet_Create Entry
In the Properties pane, set the Caption to Create Pet.
Page Caption Set To Create Pet
Now, you will add the fields (Pet name and Status) for creating a new pet record by the end-user. In the Layout Editor, expand the Static Container group. Drag and drop Form Cell section onto the Page area.
Form Cell Section Drag Drop Onto Page
Form Cell section is used to contain Form Cell controls in a section page.
You will now add Form Cell controls in the Form Cell Section. Expand the Form Cell Controls group, drag and drop a Simple Property onto the Page area.
Simple Property Control Drag Drop To Form
Drag and drop one more Simple Property control onto the page so you have two total controls.
Two Simple Property Controls On Page
Select the first Simple Property control and provide the below information:
Property
Value
Name
FCCreatePet
Caption
Pet Name
PlaceHolder
Enter Value
First Simple Property Pet Name Configuration
Select the second Simple Property control and provide the below information:
Property
Value
Name
FCCreateStatus
Caption
Status
PlaceHolder
Enter Value
Second Simple Property Status Configuration
Step 11Send data to the Backend
+
After filling-up the details for creating a new pet record, you will send these data to the backend.
In Pet_Create.page, drag & drop an action bar item to the right corner of the action bar.
Action Bar Item Added To Right Corner
In the Properties pane, click the link icon to open the object browser for the System Item property. Double click the Save type and click OK.
System Item Save Type Selection
Navigate to Events tab, click three dots icon and click create a new rule/action.
Events Tab Create New Rule Action
Keep the default selection for Object Type (as Action) and Folder path.
Default Object Type And Folder Selection
Choose REST Service in Category | select REST Service Send Request Action | Next.
REST Service Send Request Action Selected
In the Base Information, provide the below information:
Field
Value
Name
CreatePet
Service
choose petstore.service from the dropdown
Path
/pet
CreatePet Action Base Information Form
For RequestProperties object, choose POST method from the dropdown. Under Body, switch to object type by clicking the icon, once it’s color has changed, click on Body[0] to add array items, this should now display a create icon in front of Body[0]. Click Create icon to create an array item(0).
Provide the below information:
Field
Value
Key
name
Value
Bind it to input control #Control:FCCreatePet/#Value
POST Request Body Name Field Configuration
Click create icon to add another array item(1).
Field
Value
Key
status
Value
Bind it to input control #Control:FCCreateStatus/#Value
POST Request Body Status Field Added
Set FetchCSRF to false as you don’t need to obtain a CSRF token for the petstore service, and click Finish.
You can find more details about SendRequest action in help documentation.
When the CreatePet.action is successful, you may want to close the page. Expand the Common Action Properties and bind the Success Action to the CloseModalPage_Complete.action.
Success Action Bound To CloseModalPage
Step 12Add cancel button on create pet page
+
Now, you will add a button on the Pet_Create.page and set it’s onPress to ClosePage.action.
Drag and drop an Action Bar Item to the left corner of the action bar.
Action Bar Item Added To Left Corner
In the Properties pane, click the link icon to open the object browser for the System Item property. Double click the Cancel type and click OK.
System Item Cancel Type Selection
System Item are predefined system-supplied icon or text. Overwrites Text and Icon if specified.
Now, you will set the onPress event to ClosePage.action.
In Events tab, click the dotted icon for the OnPress property to open the Object Browser.
Double click the ClosePage.action and click OK to set it as the OnPress Action.
OnPress Bound To ClosePage Action
Step 13Navigate to create a new Pet Record
+
You will add a button to the Main.page called Add. When you click on this button, you want to navigate to the create pet page.
In Main.page, drag and drop an Action Bar Item to the upper right of the action bar.
Click the link icon to open the object browser for the SystemItem property.
Double click the Add type and click OK.
SystemItem Add Type Selection
Navigate to the Events tab, click the dotted icon for the OnPress property to open the Object Browser.
Events Tab OnPress Object Browser
Keep the default selection for Object Type (as Action) and Folder path.
Default Object Type And Folder Selection
Choose UI in Category | click Navigation | Next.
In the Base Information, provide the below information and click Finish.
Property
Value
Name
NavToPet_Create
PageToOpen
Select Pet_Create.page from the dropdown
ModalPage
Select true from the dropdown
Navigation Action To Pet Create Page
Step 14Redeploy the Project
+
Click the Deploy option in the editor’s header area, and then choose the deployment target as Mobile Services
Deploy To Mobile Services Option Selected
Step 15Update the app
+
Tap Check for Updates in the user menu on the Main page, you will see a New Version Available pop-up, tap Now.
New Version Available Update Prompt Android
Tap + icon on Main.page to navigate to Create Pet page.
Main Page Plus Icon Navigate Android
Fill out the details to create a new Pet record.
Create New Pet Record Form Android
Tap Check for Updates in the user menu on the Main page, you will see a New Version Available pop-up, tap Now.
New Version Available Update Prompt iOS
Tap + icon on Main.page to navigate to Create Pet page.
Main Page Plus Icon Navigate iOS
Fill out the details to create a new Pet record.
Create New Pet Record Form iOS
You have created a new record consuming REST API. Similarly, you can also modify and delete an existing record.
Share feedback on this tutorial or join the conversation in SAP Community.
Submit detailed feedbackDiscuss in Community
Steps
Step 1 of 15
1. Understand the Petstore API to retrieve data2. Create a New Project Using SAP Build3. Configure the Project Using Storyboard4. Create a new MDK Service file5. Display Pets list in MDK page6. Deploy the Project7. Display the QR code for onboarding the Mobile app8. Run the Project9. Understand the Petstore API to create new record10. Create new page for new pet record11. Send data to the Backend12. Add cancel button on create pet page13. Navigate to create a new Pet Record14. Redeploy the Project15. Update the app
Joule
AI Notice
Joule is an AI assistant. Generative AI may produce inaccurate, incomplete, or biased information. Always verify important details before acting on them.
Conversations are sent to SAP-hosted large language models for processing. Do not include personal data, credentials, or confidential information in your messages.
Joule's responses are based on the SAP tutorial catalog and may not reflect the latest product changes. For authoritative guidance, consult the linked tutorials and official SAP documentation.