Using the SAP Cloud Platform UserAPI in Mobile Services Development & Operations
Overview
The SAP Cloud Platform UserAPI provides a service which can be used to access details of the logged in user. The details of this service can be found at
https://help.hana.ondemand.com/help/frameset.htm?1de599bf722446849d2b2e10132df42a.html
This service is available to html5 applications running on the Cloud Platform. For an example of utilizing it in a html5 application see
To utilize this service in a Mobile Services application we can perform the following
STEP 1: Create HTML5 App
To utilize this service in Mobile Services we first need to create an html5 app that exposes access to the service. The only requirement for this app is to have a route defined in it’s neo-app.json for the userapi service. You can either follow the above mentioned blog, add to any existing app running on the Cloud Platform or create a new UI5 app in Web IDE and add the following entry in the neo-app.json
{
"path": "/services/userapi",
"target": {
"type": "service",
"name": "userapi"
}
}
After making the change deploy the app to the Cloud Platform. This can be done in Web IDE by right clicking on the app and choosing Deploy -> Deploy to SAP Cloud Platform. In my case I have provided the app name userapi.
STEP 2: Add connection in Mobile Services Development & Operations
In Mobile Service for Development and Operations choose the menu option Connections. Add a new connection that points to your app with /services/userapi appended to the url as shown

Set the SSO Mechanism to Application To Application SSO
Add this connection to the desired application by choosing the tab Back End of the desired application and adding the connection to the Application Connections section
STEP 3: Finalize/Test Mobile Services Application
This scenario requires that you are using SAML authentication for the Mobile Services application. This can be done by setting the Security Configuration property, found under the Information tab, of the app to Form. For more information regarding the use of SAML with Kapsel application see
https://blogs.sap.com/2017/02/02/appendix-d-saml/
You should now be able to use this connection within your Kapsel app. An example of accessing the CurrentUser would be as follows.
https://hcpms-XXXXXtrial.hanatrial.ondemand.com/userapi/currentUser
Hey Jamie,
We have a unique workflow. One where we use an edmx file from our real on-premise ODATA in WebIDE in order to build the application. Once finished, we import the archive into our local machines and aim to change the application to the ODATA backend in Java EE.
My question is how does one feed this WebIDE derived applications the serviceURL? It seems there is no guide for this in specific. I was hoping you could shed some light on it.
As you know some clients just won't allow cloud connector or WebIDE local Installation. Thank you.
Hi Shashank,
Can you please create a new post in the Questions and Answers marked with the appropriates tags for you inquiry?
Regards,
Jamie
https://answers.sap.com/questions/172763/index.html
I already have sir. Thank you for your response. We really require a solution.
Hi Jamie,
I’m working with a NO-trial HCPMS. My back-end url is https://xxx-xxxxxxxxx.dispatcher.hana.ondemand.com/services/userapi. This URL from chrome works.
On HCPMS destination creation wizard on SAML2 Audience field, the https://xxxxxxxxx.accounts.ondemand.com/saml2/idp/sso/xxxxxxxxx.accounts.ondemand.com value is cutted, it doesn’t enter entirely. I try just with:
–https://xxxxxxxxx.accounts.ondemand.com/saml2
–https://xxxxxxxxx.accounts.ondemand.com/saml2/idp/sso
But the calling throw ajax on my mobile app doesn’t work. My ajax:
I receive this HTML response by SAML IDP:
Could you help me please?
Thanks,
Luca
Can you please create a new post in the Questions and Answers marked with the appropriates tags for you inquiry?
Regards,
Jamie
Hello Luca,
It would be great if could please share how was it resolved.
I am facing the same issue.
Regards,
Ajay
Hi Jamie,
Thanks for the very useful blog.
Would you know how to consume the same API using the SCP iOS SDK?
Cheers,
Greg