Skip to Content
Technical Articles

Connect to SAP API Business Hub from an MDK app

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.

 

 

Steps:

 

Find an API from SAP API business Hub

  1. Log on to https://api.sap.com/ and look for an API. For this blog post, i have chosen SAP S/4HANA Cloud and then this below API

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.

 

 

https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/API_CUSTOMER_MATERIAL_SRV/

 

Configure application in SAP Cloud Platform Mobile Services Cockpit

 

  1. Make sure you have enabled Mobile Services in SAP Cloud Platform. Login to SAP Cloud Platform Mobile Services cockpit

open https://account.hanatrial.ondemand.com/cockpit/#/home/trialhome and click on “Neo Trial”

2. Click on “services” and look for “Mobile” category.

3. Click on it and then click on “Go to service”

4. In Mobile Services cockpit, Click on “Create new app”

5. provide below details:

Config Templates Mobile development kit
ID com.sap.mdk.apihub
Name SAP MDK APIHub App

 

6. Click on “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

and in the end: 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

 

 

e.g.

 

Create an MDK app using Master-detail template in SAP Web IDE

 

  1. Open SAP Web IDE Full stack , make sure you have enabled “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 and follow mentioned steps

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. While deploying the app metadata to Mobile Services, i have chosen only UPLOAD option since i didn’t want to download metadata to my local machine and didn’t need to include source map file for debugging.

Please keep in mind, you should select same Application ID that you have chosen while creating a service (part of project creation)

 

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:

 

Here you can find more info on SAP Mobile development kit

New to MDK development?

Regards

Jitendra Kansal

Product Management, SAP Cloud Platform Mobile Services
SAP SE

Be the first to leave a comment
You must be Logged on to comment or reply to a post.