cancel
Showing results for 
Search instead for 
Did you mean: 

Using the SAP HCP User API in SUCCESS FACTORS EXTENSION (SAPUI5)

FedericoB
Explorer
0 Kudos

Hi!

I am creating an SAPUI5 application to extend SUCCESS FACTORS. Within the application, I am using the User SCP API, to obtain the logged in user.

But when I test the application in SuccessFactors, the api returns 404 error.

Inside attachRequestCompleted, it always returns error: 404 - Error report

My code:

	var oModel = new sap.ui.model.json.JSONModel();
        // Load the data 
	oModel.loadData("/services/userapi/currentUser");
	// Add a completion handler to log the json and any errors
	oModel.attachRequestCompleted(function onCompleted(oEvent) {
				if (oEvent.getParameter("success")) {
				 var _User = oModel.getData();
				 this.setData({
						"json": this.getJSON(),
						"status": "Success"
					}, true);
				} else {
					var msg = oEvent.getParameter("errorObject").textStatus;
					if (msg) {
						this.setData("status", msg);
					} else {
						this.setData("status", "Unknown error retrieving user info");
					}
				}
			});

Accepted Solutions (1)

Accepted Solutions (1)

FedericoB
Explorer
0 Kudos

I FOUND THE SOLUTIN!

window.sap.ushell.Container.getUser().getId();

WARNING! This works in the application inside SF but it does not work when it is being tested in WEBIDE.

Answers (0)