These examples of JavaScript code show how to perform basic functions of the REST API. You can study the logic, then implement in the programming language of your choice.
The examples can be run if you want. To run them:
HTML File to run examples
Copy Code
|
|
---|---|
<html> <!-- Place this page in a folder under qcbin on the server. --> <!-- Place all the javascript files in the same folder. --> <head> <script type="text/javascript" src="base64.js"></script> <!-- used by session_Flow.js --> <script type="text/javascript" src="session_Flow.js"></script> <script type="text/javascript" src="CRUD_Instance.js"></script> <script type="text/javascript" src="get_Collection.js"></script> <script type="text/javascript" src="get_PagedData.js"></script> <script type="text/javascript" src="post_delete_Lock.js"></script> <script type="text/javascript" src="crud_File.js"></script> <script type="text/javascript" src="get_MetaData.js"></script> <script type="text/javascript"> alm_api = "http://localhost:8080/qcbin/api"; alm_domain_name = "default"; alm_project_name = "test_prj"; alm_project_url = alm_api + "/domains/" + alm_domain_name + "/projects/" + alm_project_name; function performMainLogic() { //performCRUDInstance(); // see CRUD_Instance.js //performGetDefects(true); // see get_Collection.js //performGetListItems(); // see get_Collection.js //performGetPagedDefects(true); // see get_PagedData.js //performGetPagedListItems(); // see get_PagedData.js //performPostDeleteLock(); // see post_delete_Lock.js //performGetFieldsMetadata() // see get_MetaData.js } window.onload = function () { console.log("Working..."); performSignin("sa", ""); try { performMainLogic(); } catch (e) { console.log("performMainLogic failed:", e.message); } performSignout(); console.log("end."); } </script> <script type="text/javascript"> function upload() { performCRUDFile(); // see crud_File.js } </script> </head> <body> <input type="file" name="uploadfile" id="uploadfile"/> <input type="button" value="upload" onclick="upload()"/> </body> </html> |
The examples provided are:
There is also a Metadata Example that is not run from the HTML file.