🎓intermediate⏱30 min.Mobile Development Kit ClientIntermediateIosAndroidMobileSAP Business Technology PlatformSAP Mobile ServicesSAP Build CodeSAP BuildSAP Business Application Studio
You will learn
โHow to create a mobile project in SAP Build Lobby
โHow to configure a Mobile Services application in SAP Business Application Studio via Storyboard
โHow to configure a REST endpoint as a destination in Mobile Services application
โHow to create a MDK Service file pointing to REST endpoint destination
โHow to use RestService SendRequest Action to make directly call to Petstore API
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.
MDK
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.
MDK
Click the Application tile and choose Next.
MDK
Select the Mobile category and choose Next.
MDK
Select the Mobile Application to develop your mobile project in SAP Business Application Studio and choose Next.
MDK
Enter the project name mdk_petstore (used for this tutorial) , add a description (optional), and click Review.
MDK
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.
MDK
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.
MDK
The project opens in SAP Business Application Studio.
MDK
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.MDK
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.
MDK
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.
MDK
Click on the + button to add a new mobile services app configuration.
MDK
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
MDK
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
MDK
Mobile Services App may take 2-3 minutes in creating the required configuration. You will notice the app state as Creating.
MDK
Once the app is in Created state, click Add App to Project.
MDK
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.
MDK
Click the + button in the UI application column header to add mobile UI for your project.
MDK
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.
MDK
After clicking Finish, the storyboard is updated displaying the UI component. The MDK project is generated in the project explorer based on your selections.
MDK
Step 4Create a new MDK Service file
+
Right-click the Services folder | MDK: New Service.
MDK
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
MDK
.service and .xml (empty file) have been created under the Services folder.
MDK
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.
MDK
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
MDK
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}
MDK
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.
MDK
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.
MDK
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 .
MDK
Select deploy target as Mobile Services.
MDK
If you want to enable source for debugging the deployed bundle, then choose Yes.
MDK
You should see Deploy to Mobile Services successfully! message.
MDK
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.
MDK
The On-boarding QR code is now displayed.
MDK
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.
MDK
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.
MDK
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.
MDK
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.
MDK
In the Base Information step, enter the Page Name as Pet_Create and click Finish.
MDK
In the Properties pane, set the Caption to Create Pet.
MDK
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.
MDK
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.
MDK
Drag and drop one more Simple Property control onto the page so you have two total controls.
MDK
Select the first Simple Property control and provide the below information:
Property
Value
Name
FCCreatePet
Caption
Pet Name
PlaceHolder
Enter Value
MDK
Select the second Simple Property control and provide the below information:
Property
Value
Name
FCCreateStatus
Caption
Status
PlaceHolder
Enter Value
MDK
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.
MDK
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.
MDK
Navigate to Events tab, click three dots icon and click create a new rule/action.
MDK
Keep the default selection for Object Type (as Action) and Folder path.
MDK
Choose REST Service in Category | select REST Service Send Request Action | Next.
MDK
In the Base Information, provide the below information:
Field
Value
Name
CreatePet
Service
choose petstore.service from the dropdown
Path
/pet
MDK
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
MDK
Click create icon to add another array item(1).
Field
Value
Key
status
Value
Bind it to input control #Control:FCCreateStatus/#Value
MDK
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.
MDK
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.
MDK
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.
MDK
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.
MDK
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.
MDK
Navigate to the Events tab, click the dotted icon for the OnPress property to open the Object Browser.
MDK
Keep the default selection for Object Type (as Action) and Folder path.
MDK
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
MDK
Step 14Redeploy the Project
+
Click the Deploy option in the editor’s header area, and then choose the deployment target as Mobile Services
MDK
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.
MDK
Tap + icon on Main.page to navigate to Create Pet page.
MDK
Fill out the details to create a new Pet record.
MDK
Tap Check for Updates in the user menu on the Main page, you will see a New Version Available pop-up, tap Now.
MDK
Tap + icon on Main.page to navigate to Create Pet page.
MDK
Fill out the details to create a new Pet record.
MDK
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.