Last week, i was asked from one of our internal teams on how to connect to SAP API Business Hub end point from a Mobile development kit application. It might be helpful for others if looking for similar requirement.
FYI: Mobile development kit (MDK) : Mobile development kit is a feature in SAP Cloud Platform Mobile Services, it is a metadata-driven tool that allows users to customize native SAP applications, as well as rapidly create new native mobile applications for Android and iOS. Mobile development kit uses SAP Web IDE Full-Stack and the SAP Cloud Platform to enable you to customize, deploy, and manage mobile apps in the cloud.
SAP API Business Hub is one stop shop or central catalog of SAP and selected partner APIs where you can discover, search, test, consume APIs in building solution like extending Line of Business (LoB) apps, developing a mobile apps etc. Please check https://api.sap.com/ for more details.
- Find an API from SAP API business Hub
- Configure application in SAP Cloud Platform Mobile Services Cockpit
- Create an MDK app using Master-detail template in SAP Web IDE
- Run this app in standard MDK client
Find an API from SAP API business Hub
- Log on to https://api.sap.com/ and search with required API. For this blog post, i have chosen OData API from SAP S/4HANA Cloud and then this below API
Click on Customer material
2. Click on “Show API Key” and copy it (make sure that you have logged on to the same page)
3. now, let’s test one of it’s operation and also to find it’s endpoint URL.
Click on “Try it out”
4. scroll down and then click on “Execute” . (i am not modifying any of the parameters, leaving it to default)
5. note down Request URL.
Configure application in SAP Cloud Platform Mobile Services Cockpit
1. in SAP Cloud Platform Mobile Services cockpit, configure a new app.
|Name||SAP MDK APIHub App|
2. Select Mobile Development Kit Application from drop-down > Finish
6. Click on “Mobile Connectivity” to add a new backend endpoint
7. Click on “create” icon
follow below steps:
8. Enter URL as copied above (make sure there is no blank space in the end)
Custom Headers: since to access this api endpoint, we need to provide APIKey. So create a custom header APIKey and provide it’s value
select SSO mechanism as NoAuth
9. you can also cross check if backend data is accessible from Mobile Services by clicking on below circled icon
Create an MDK app using Master-detail template in SAP Web IDE
- Open SAP Web IDE Full stack , make sure you have enabled Enable Mobile Services App Development Tools extension
2. In SAP Web IDE, there is a dedicated MDK Development environment , click to it and right click on workspace create a new MDK app – select List-Detail project
3. give it a name and click next
In service creation screen, provide a name to service, select app id & destination configured in Mobile Services cockpit.
(Since we are connecting to Mobile Services on Cloud Foundry from SAP Web IDE NEO environment, we need to setup a destination in Cloud platform cockpit pointing to Mobile Services Cloud Foundry)
You need to click on “Check service” for WebIDE to retrieve service metadata
4. Once you see Success message, click on Next
here in this metadata source page, select “entity type” , since there is only one so select this (there could be more list of entity types, you need to select based on requirement) and then adjust binding page elements (you could also go with default filled up details)
5. in next screen, you can customize the template .e.g. put a filter or skip query or rename page names (i didn’t modify any parameter)
6. here in this optional features, you could modify queries for offline data initialization.
7. once project creation done, right click on project and select “MDK Deploy and activate”
8. Let the default configuration as it is and click Next.
Confirm the destination name and application id match where you want to deploy.
Once done, you should see a success message in console logs.
Run this app in standard MDK client
I am going with App store MDK client , here you can find more details how to prepare on-boarding in details , end result looks like below:
New to MDK development?
Follow these tutorials to learn more about Mobile development kit
- Create your Mobile Development Kit (MDK) app in SAP Business Application Studio
- MDK documentation:
Product Management, SAP Cloud Platform Mobile Services