Note samples
Basics
Section titled “Basics”On most methods, you’ll see the parameter named “nodeId”. The value of this parameter can be a valid document, folder, mail or record UUID.
Suggested code sample
Section titled “Suggested code sample”First, you must create the webservice object:
OKMWebservices ws = OKMWebservicesFactory.newInstance(host);Then should login using the method “login”. You can access the “login” method from webservice object “ws” as is shown below:
ws.login(user, password);At this point you can use all the Note methods from “note” class as is shown below:
ws.note.addNote("373bcdd0-c082-4e7b-addd-e10ef813946e", "the note text");Methods
Section titled “Methods”addNote
Section titled “addNote”Description:
| Method | Return values | Description |
|---|---|---|
| addNote(String nodeId, String text) | Note | Adds a note to a node and returns an object Note. |
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);
try{ws.login(user, password);ws.note.addNote("f123a950-0329-4d62-8328-0ff500fd42db", "the note text");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getNote
Section titled “getNote”Description:
| Method | Return values | Description |
|---|---|---|
| getNote(String noteId) | Note | Retrieves the note. |
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);
try{ws.login(user, password);List<Note> notes = ws.note.listNotes("f123a950-0329-4d62-8328-0ff500fd42db");if (notes.Count > 0){System.Console.WriteLine(ws.note.getNote(notes[0].path));}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}deleteNote
Section titled “deleteNote”Description:
| Method | Return values | Description |
|---|---|---|
| deleteNote(String noteId) | Note | Deletes a note. |
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);
try{ws.login(user, password);List<Note> notes = ws.note.listNotes("f123a950-0329-4d62-8328-0ff500fd42db");if (notes.Count > 0){ws.note.deleteNote(notes[0].path);}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}setNote
Section titled “setNote”Description:
| Method | Return values | Description |
|---|---|---|
| setNote(String noteId, String text) | void | Changes the note text. |
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);
try{ws.login(user, password);List<Note> notes = ws.note.listNotes("f123a950-0329-4d62-8328-0ff500fd42db");if (notes.Count > 0){ws.note.setNote(notes[0].path, "text modified");}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}listNotes
Section titled “listNotes”Description:
| Method | Return values | Description |
|---|---|---|
| listNotes(String nodeId) | List |
Retrieves a list of all notes of a node. |
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);
try{ws.login(user, password);List<Note> notes = ws.note.listNotes("f123a950-0329-4d62-8328-0ff500fd42db");foreach (Note note in notes){System.Console.WriteLine(note);}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getNotesHistory
Section titled “getNotesHistory”Description:
| Method | Return values | Description |
|---|---|---|
| getNotesHistory(String nodeId) | List |
Retrieves a list of all notes of a node. |
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);
try{ws.login(user, password);List<NoteHistory> notes = ws.note.getNotesHistory("f123a950-0329-4d62-8328-0ff500fd42db");foreach (NoteHistory note in notes){System.Console.WriteLine(note);}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}