Skip to Content
Technical Articles

Connect to SAP API Business Hub from an MDK app

Last Updated: 05-May-2021

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.

The SAP Mobile Development Kit enables developers and technical business users to build multi-channel applications. It allows you to build your application once, in an integrated development environment, and run it natively on mobile devices (Android & iOS) and as a web application (online) in the browser.

 

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 search Customer Material (SAP S4/HANA Cloud).
  2. Click on Customer material (A2X)

3. Click on “Show API Key” and copy/paste it’s value in a text pad. (make sure that you have logged on to the same page)

 

4. Now, let’s test one of it’s operation and also to find it’s endpoint URL.

Click on “Try out”

5. scroll down and then click on “Execute” . (i am not modifying any of the parameters, leaving it to default)

6. Note down Request URL.

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

Configure application in SAP Mobile Services Cockpit

MDK Mobile applications access the data source via Mobile Services destination.

1. In SAP Mobile Services cockpit, configure a new app.

ID com.sap.mdk.apihub
Name SAP MDK APIHub App

2.  Select Mobile Development Kit Application from drop-down > Finish

3. Click on “Mobile Connectivity” to add the API Hub endpoint

4. Click on “create” icon

5.Provide below information

Destination Name CustomerMaterial
URL https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/API_CUSTOMER_MATERIAL_SRV
Customer Header APIKey: <value>
SSO Mechanism No Authentication

 

6. you can also cross check if back-end data is accessible from Mobile Services by clicking on below circled icon

e.g.

 

Create a new destination to your MDK Web application

MDK Web applications access the data source via BTP destination.

  1. Navigate to Destinations to create an BTP destination.
  2. Provide below info
Name CustomerMaterial
URL https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/API_CUSTOMER_MATERIAL_SRV
Proxy Type Internet
Authentication NoAuthentication
Additional properties
  • HTML5.DynamicDestination: true
  • WebIDEEnabled: true
  • WebIDEUsage: odata_gen

Start Your MDK Application in the Editor

 

Make sure to set up SAP Business Application Studio for Multi-Channel Development.

  1. Create a new MDK project by clicking Start from template option in Welcome page (if you don’t see Welcome page, launch it from Help menu)

2. Provide basic information

3.In Service Configuration step, select Mobile Services OData Source and app configuration details

4. In OData Collections step, select data collections and Finish the project creation.

5. In order for MDK Web applications to access the data, you need to provide APIKey value in a custom header.

Open CustomerMaterial.service file > Headers

Deploy the Application

  1. Right-click Application.app and select MDK: Deploy.

2. Select deploy target as Mobile & Cloud.

MDK editor will deploy the metadata to Mobile Services (for Mobile application) followed by to Cloud Foundry (for Web application).

 

 

Run the Application

To run the app in Mobile client

  • Download and install SAP Mobile Services Client on your iOS or Android device
  • Double-click the Application.app to open it in MDK Application Editor and click Application QR Code icon to populate the QR code
  • Follow the steps (iOS/Android) to on-board the MDK client

To run the app in Web browser:

  • Click the highlighted button to open the MDK Web application in a browser. Enter your SAP BTP credentials if asked. (You can also open the MDK web application by accessing its URL from .project.json file.)

 

New to MDK development?

Follow these tutorials to learn more about Mobile development kit

 

Regards

Jitendra Kansal

Product Management, SAP Mobile Services
SAP SE

1 Comment
You must be Logged on to comment or reply to a post.