on 2018 Jun 13 4:07 PM
I have to develop a sapui5 application with the sap web ide: the user must be enabled to perform CRUD operations on the SAP Cloud Platform Identity Authentication (URL: "https: // <tenant-id> .accounts.ondemand.com / service / scim / Users ") via app and manage users. First I tested it on Postman successfully. Later I tried to make an AJAX call (directly on the controller.js) to get a json with all the users already registered on the SAP Identity Authentication. This is the code:
var username = "T000034";
var password = "012345";
var url = "https://<tenant-id>.accounts.ondemand.com/service/scim/Users";
$.ajax({
url: url,
async: true,
type:'GET',
dataType: 'json',
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Basic "+btoa(username+':'+password));
},
success: function(json){ console.log(json); },
error: function(err) { console.log(err); } });
In the console after several attempts I get the following error:
"Failed to load resource: the server responded with a status of 401 (Unauthorized) extension_runnable_file.html? hc_orionpath =% 2Fs0*********03trial% 24s0*********03-OrionContent% 2Faaaaaa & origional-url = index.html & sap-ui-appCacheBuster = ..% 2F & sap-ui-xx-componentPreload = off: 1 Failed to load https: // <tenant-id > .accounts.ondemand.com / service / scim / Users:
Response for preflight has invalid HTTP status code 401. "
What's wrong? Any suggestions?
Request clarification before answering.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sebastian thanks for answer. In this case I have to add to neo-app.json the Identity Auth Service destination, right?
So then how can i do the AJAX call?
Hey Eugenio,
yes, you have to add the destination to you neo-app.json.
...
{
"path": "/service/scim/Users",
"target": {
"type": "destination",
"name": "Users"
},
"description": "Users from Identity Authentication Service"
}
...
I would suggest that you load the users in your manifest so that you don't have to make an seperate Ajax-Call:
... service...
...
"userService": {
"uri": "/service/scim/Users",
"type": "JSON",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
...
... models ...
...
"userData": {
"dataSource": "userService",
"type": "sap.ui.model.json.JSONModel",
"preload": true
}
...
Then you have the users in your JSONModel "userData"
Greetings,
Sebastian
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.