Record samples
On most methods, you’ll see the parameter named “recId”. The value of this parameter can be a valid record UUID or path.
Methods
Section titled “Methods”createRecord
Section titled “createRecord”Description:
| Method | Return values | Description |
|---|---|---|
| createRecord(Record record) | Record | Creates a new record and returns as a result an object Record. |
- The variable path into the parameter record must be initialized. It indicates the folder path into OpenKM.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password); try { Record record = new Record(); record.path = "/okm:root/PKI-100200"; record.title = "some title"; ws.createRecord(record); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getRecordProperties
Section titled “getRecordProperties”Description:
| Method | Return values | Description |
|---|---|---|
| getRecordProperties(String recId) | Record | Returns the record properties. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password); try { System.Console.WriteLine(ws.getRecordProperties("/okm:root/PKI-100200")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}deleteRecord
Section titled “deleteRecord”Description:
| Method | Return values | Description |
|---|---|---|
| deleteRecord(String recId) | void | Deletes a record. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password); try { ws.deleteRecord("/okm:root/PKI-100200"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}purgeRecord
Section titled “purgeRecord”Description:
| Method | Return values | Description |
|---|---|---|
| purgeRecord(String recId) | void | Records are definitely removed from the repository. |
- Usually, you will purge records into /okm:trash/userId - the personal trash user locations - but is possible to directly purge any record from the whole repository.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password); try { ws.purgeRecord("/okm:trash/okmAdmin/PKI-100200"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}renameRecord
Section titled “renameRecord”Description:
| Method | Return values | Description |
|---|---|---|
| renameRecord(String recId, String newName) | void | Renames a record. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password); try { ws.renameRecord("/okm:root/PKI-100200", "new_name"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}moveRecord
Section titled “moveRecord”Description:
| Method | Return values | Description |
|---|---|---|
| moveRecord(String recId, String dstId) | void | Moves a record into a folder or record. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password); try { ws.moveRecord("/okm:root/PKI-100200", "/okm:root/tmp"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}copyRecord
Section titled “copyRecord”Description:
| Method | Return values | Description |
|---|---|---|
| copyRecord(String recId, String dstId, String newName) | void | Copies a record into a folder or record. |
- The values of the dstId parameter should be a folder or record UUID or path.
- When parameter newName value is null, the record will preserve the same name.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password); try { ws.copyRecord("/okm:root/PKI-100200", "/okm:root/tmp", "new_name"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}isValidRecord
Section titled “isValidRecord”Description:
| Method | Return values | Description |
|---|---|---|
| isValidRecord(String recId) | Boolean | Returns a boolean that indicates if the node is a record or not. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password); try { System.Console.WriteLine("Is a record:"+ws.isValidRecord("/okm:root/PKI-100200")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getRecordChildren
Section titled “getRecordChildren”Description:
| Method | Return values | Description |
|---|---|---|
| getRecordChildren(String fldId) | List |
Returns a list of all records which their parent is fldId |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password); try { foreach (Record rec in ws.getRecordChildren("/okm:root/folder")) { System.Console.WriteLine(rec); } } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}lockRecord
Section titled “lockRecord”Description:
| Method | Return values | Description |
|---|---|---|
| lockRecord(String recId) | LockInfo | Locks a record and returns an object with the Lock information |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password); try { ws.lockRecord("/okm:root/PKI-100200"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}unlockRecord
Section titled “unlockRecord”Description:
| Method | Return values | Description |
|---|---|---|
| unlockRecord(String recId) | void | Unlocks a locked record. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password); try { ws.unlockRecord("/okm:root/PKI-100200"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}forceUnlockRecord
Section titled “forceUnlockRecord”Description:
| Method | Return values | Description |
|---|---|---|
| forceUnlockRecord(String recId) | void | Unlocks a locked record. |
- This method allows unlocking any locked record.
- It is not mandatory to execute this action by the same user who previously executed the checkout lock action.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password); try { ws.forceUnlockRecord("/okm:root/PKI-100200"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}setRecordTitle
Section titled “setRecordTitle”Description:
| Method | Return values | Description |
|---|---|---|
| setRecordTitle(String recId, String title) | void | Sets a record title. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password); try { ws.setRecordTitle("/okm:root/PKI-100200", "some title"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getRecordPath
Section titled “getRecordPath”Description:
| Method | Return values | Description |
|---|---|---|
| getRecordPath(String uuid) | String | Converts a record UUID to record path. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password); try { System.Console.WriteLine(ws.getRecordPath("28bb0c8b-3701-4457-a81a-fef7bc56ff33")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}