[Updated] : Blog content updated considering latest release of SAP Cloud Platform SDK for iOS 3.0 SP01 Assistant UX (You might have already read my colleague Andreas blog post on what’s new in latest SAP Cloud Platform SDK for iOS 3.0 SP01)
SAP API Business Hub integration in SAP Cloud Platform SDK for iOS Assistant is available since it’s 2.0 release.
FYI: 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.
In this blog post, i am going to tell you how you can incorporate an API (from Public API Business Hub) into an native iOS application.
Here is my assistant app (part of SAP Cloud Platform SDK for iOS 3.0 SP01)
- Click on ‘Create New’ option
2. Then click on “create new Application” option
3. Select an SAP Cloud Platform Mobile Services account from available existing accounts. (In case if you haven’t added one, click on “Add New” and provide required info) and then click on “Next”
(There are maximum limit of 5 applications per SAP Cloud Platform Mobile Services trial account, keep in mind about this restriction when you create a new app. If have reached limit, you can delete any existing app from Mobile Services cockpit )
4. Provide below info:
Name: Name for your application in SAP Cloud Platform Mobile Services
Identifier: Unique value for identifier for the app in SAP Cloud Platform Mobile Services
Authentication: Choose one either of available
And then click on “Next”
5. Next step is where we need to add or reuse an OData service. Since in this blog, focus is on how to integrate an API Business hub endpoint in SAP Cloud Platform SDK for iOS Assistant, so click on “Add new from API Management” option
6. Select “SAP API Business Hub” account, click “Next”
7. In this screen, you will see list of API Products available in SAP Business Hub. For this blog post, i have decided to go with SAP S/4HANA Cloud one.
8. In this screen, you will see list of available artifacts for SAP S/4HANA Cloud product, choose “Credit Memo Request” and then click on “Next”
9. Now, you should where this API is pointing to either sandbox or production and its respective URL , for this blog post, i am using sandbox option, click on “Next”
10. You will see more details about “destination” , this is similar screen you might have seen when you add a new destination in mobile services app. Give it a name then click on “Save”
Since URL scheme is HTTPS, assistant tool has auto set Proxy type as Internet
URL Rewrite mode is as “Rewrite URL” that means this mode allows SAP CP mobile service to replace all back-end URLs with mobile service URL. read here for more details.
Under Authentication, as this API is from sandbox system so no authentication required. Assistant set it by its own.
11. After clicking on “save” , you see here that destination “apihub” has been selected, now click on “Next”
12. Give a name to your Xcode project and then click on Finish
13. Run this project in simulator
14. Go through and follow on-boarding flow and then you will see list of collections followed by details.
Lets try to update an entry here, in doing so, you will see failed message, this is because only HTTP GET/READ is supported against APIs from sandbox system. Data modification (create, update, delete, upsert) requests are not allowed.
Note: All services from sandbox version requires an API key, since we have created this app using Assistant, behind the scene, assistant automatically retrieves API key , we are not manually entering the API key, and this fetched API key is saved withe destination in SAP Cloud Platform mobile services. You can always reuse that destinations in other mobile apps. For Product version API, its upto publisher to enable API key mandatory in order to access APIs.
Check below resources for more information:
Thanks for reading.
Product Management, SAP Cloud Platform User Experience