Skip to Content
Author's profile photo Former Member

A simple example consuming SAP Identity Management REST API

Dear community,

as I am often getting the question how to build a simple example using the SAP Identity Management REST API, I am writing a small blog post about it.

  • Attached, you are able to find a text file. Download it do a directory of your choice and rename it to index.html.
  • Download the jQuery library from following location and save it to the same directory as jquery-1.9.1.min.js:

http://code.jquery.com/jquery-1.9.1.min.js

  • Edit the index.html file with a plain text editor (e.g. Sublime Text) and change the host definition, so that it fit’s your environment:

var baseUrl = ‘http://localhost:50000/idmrest/v1′;

  • After storing the file, open it with a browser (e.g. Goggle Chrome), and execute the “Search for Users” functionality. You will be prompted for username/password. As result, you should see a list of MX_PERSON entries.
  • Afterwards, execute the “Get Data from Display Task” functionality for a valid MSKEY, and you will see the attributes of this entry.

With the Google Chrome Developer Tools, you are easily able to look behind the scenes and which data is moved over the wire.

I recommend following  pages and tutorials for further information:

http://en.wikipedia.org/wiki/Ajax_(programming)

http://en.wikipedia.org/wiki/Representational_state_transfer

http://en.wikipedia.org/wiki/JSON

https://developer.mozilla.org/en-US/docs/AJAX/Getting_Started

https://developers.google.com/chrome-developer-tools/

In addition to following blog posts:

Write your own UIs using the ID Mgmt REST API

SAPUI5 and ID Mgmt – A Perfect Combination

Jannis

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo C Kumar
      C Kumar

      Hello Jannis,
      Could you please attach the text file again. It seems after the migration, the attachment has been removed.

       

      Regards,

      C Kumar

      Author's profile photo Kelvin Robinson
      Kelvin Robinson

      I was able to dig up the index.html file in case anyone still needed it.  I’ve pasted it here in its entirety.

       

      <!DOCTYPE HTML>
      <html>
      <head>
      <meta http-equiv=”X-UA-Compatible” content=”IE=edge”>
      <meta charset=”UTF-8″>
      <script type=”text/javascript” src=”jquery-1.9.1.min.js”></script>

      <script type=”text/javascript”>

      var baseUrl = ‘<your server address>:50000/idmrest/v1’;

      function searchEntries(entryType) {
      $.ajax({
      type: ‘GET’,
      url: baseUrl + ‘/entries?EntryType=’ + entryType,
      dataType:’jsonp’,
      success: function _success(response){
      var result = ”;
      response.ENTRIES.forEach(function (entry){
      result = result + ‘MSKEY:’ + entry.MSKEY + ‘, MSKEYVALUE:’ + entry.MSKEYVALUE + ‘<br>’;
      });
      $(‘#userSearchResult’).html(result);
      },
      error: function _error(request, status, error) {
      alert(request.responseText);
      }
      });
      };

      function getDisplayTask() {
      var mskey = $(‘#mskey’).val();
      $.ajax({
      type: ‘GET’,
      url: baseUrl + ‘/entries/’+mskey+’/tasks/0′,
      dataType:’jsonp’,
      success: function _success(response){
      var result = ”;
      $.each(response.ENTRIES, function(key, element) {
      result = result + ‘Attribute: ‘ + key + ‘, Value: ‘ + element.VALUE + ‘<br>’;
      });
      $(‘#getDisplayTaskResult’).html(result);
      },
      error: function _error(request, status, error) {
      alert(request.responseText);
      }
      });
      };

      </script>
      </head>

      <body>

      <h1>Search for Users</h1>
      <div><input type=”button” id=”searchUsers” name=”searchUsers” value=”Search for Users” onClick=”searchEntries(‘MX_PERSON’)”/></div>
      <div id=”userSearchResult”></div>
      <hr>

      <h1>Get Data from Display Task</h1>
      <div>MSKEY:<input type=”text” id=”mskey” name=”mskey” value=””/></div>
      <div><input type=”button” id=”getDisplayTask” name=”getDisplayTask” value=”Get Data from Display Task” onClick=”getDisplayTask()”/></div>
      <div id=”getDisplayTaskResult”></div>
      <hr>

      </body>
      </html>