Table of Contents

Search

  1. Preface
  2. Introduction to Business Entity Services
  3. EJB Business Entity Service Calls
  4. REST Business Entity Service Calls
  5. REST APIs for Data Director
  6. SOAP Business Entity Service Calls
  7. Cross-reference Records and BVT Calculations Services
  8. Supporting Corporate Linkage Service
  9. External Calls to Cleanse, Analyze, and Transform Data
  10. Appendix A: Using REST APIs to Add Records
  11. Appendix B: Using REST APIs to Upload Files
  12. Appendix C: Using REST APIs to Manage Reports

JavaScript Example

JavaScript Example

The resource kit has sample Java source code that shows how to make REST business entity service calls.
The sample code is in the following file:
<
MDM Hub installation directory
>\hub\resourcekit\samples\COS\source\resources\webapp\rest-api.html
The following code shows REST API calls to create a person root record, add multiple child records, delete one child record, and then delete the person record and all child records:
<html> <head> <script type="text/javascript" src="jquery-1.11.1.js"></script> <script type="text/javascript" src="cs-client.js"></script> </head> <body> <script type="text/javascript" language="javascript"> $(document).ready(function () { $("#run").click(function () { log = function(msg, json) { $('#log').before("<hr/><b>" + msg + "</b>"); $('#log').before("<pre>" + JSON.stringify(json, undefined, 2) + "</pre>"); }; CSClient.createCo( "/Person", { firstName: "John", lastName: "Smith" }, { systemName: "Admin" } ).then( function (result) { log("PERSON CREATED:", result); return CSClient.readCo( "/Person/" + result.Person.rowidObject.trim(), { depth: 1 } ); } ).then( function (result) { log("READ CREATED PERSON:", result); return CSClient.updateCo( "/Person/" + result.rowidObject.trim(), { genderCd: { genderCode: "M" }, TelephoneNumbers: { item: [ { phoneNumber: "111-11-11" }, { phoneNumber: "222-22-22" } ] } }, { systemName: "Admin" } ); } ).then( function (result) { log("PERSON UPDATED:", result); return CSClient.readCo( "/Person/" + result.Person.rowidObject.trim(), { depth: 3, readSystemFields: true } ); } ).then( function (result) { log("READ UPDATED PERSON:", result); return CSClient.deleteCo( "/Person/" + result.rowidObject.trim() + "/TelephoneNumbers/" + result.TelephoneNumbers.item[0].rowidObject.trim(), { systemName: "Admin" } ); } ).then( function (result) { log("TELEPHONE DELETED:", result); return CSClient.readCo( "/Person/" + result.Person.rowidObject.trim(), { depth: 3 } ); } ).then( function (result) { log("READ PERSON AFTER TELEPHONE IS DELETED:", result); return CSClient.deleteCo( "/Person/" + result.rowidObject.trim(), { systemName: "Admin" } ); } ).then( function (result) { log("PERSON DELETED:", result); return CSClient.readCo( "/Person/" + result.Person.rowidObject.trim(), { depth: 1, recordStates: "ACTIVE,PENDING,DELETED", readSystemFields: true } ); } ).then( function (result) { log("READ PERSON AFTER DELETE (HSI -1):", result); } ); }); }); </script> <input type="button" id="run" value="Run..."/> <p/> <div id="log"></div> </body> </html>

0 COMMENTS

We’d like to hear from you!