You might have already read my colleague Andreas blog post on what’s new in latest SAP Cloud Platform SDK for iOS 2.0
There are so many new features have been added in Assistant tool (a native MacOS app) and one of them is SAP API Business Hub Integration.
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 2.0)
Click on ‘+‘ icon, provide all required details like Product name, Organization Identifier
(you can always do similar steps for an existing app, for this blog post , i am creating app from scratch)
2. Under “Project Properties”
3. Click on “Next” , under “Cloud Integration”
(Here again you can select existing app already created on Mobile service, here, i am going to create a new Application, also, make sure that if you have selected Account as SAPCPms Trial, you should not have more than 2 apps already created as you can have max of 3 apps in that account , SAP Cloud Platform Trial limitation applies otherwise you may ended with an error message while doing so)
(For authentication Type, you got option of selecting NoAuth, Basic, SAML, OAuth)
4. Click on “Next” , under “Destination”
Click on + icon, select “New Destination to a Service from the API Business Hub”
5. you will be prompted a page with list of API Products and respective API, lets select one and click on consume
(this particular API is from SAP S4HANA Cloud system which can be used for external apps to integrate with read methods for processing credit memo requests in that particular system.For more details about API, click on Arrow icon )
6. 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
7. Click on “Next“, you wil see more details about “destination” , this is similar screen you might have seen when you add a new destination in mobile services app
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.
and then let other settings be there as it is. (you can change of course as per your needs)
8. Click ok , next, finish.
Assistant is creating an Xcode project, connecting to backend, download its metadata , creating proxy classes along with scaffolding UI. open generated project into Xcode 9
Note: If you have not selected option under General in Assistant to open new project in Xcode automatically, you can do it here.
9. Run this project in iPhone X (iOS 11) simulator
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 for development and operations. 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