Note samples
Basics
In most methods, you'll see the parameter named "nodeId". The value of this parameter can be a valid document, folder, mail or record UUID.
Example of nodeId:
- Using UUID -> "f123a950-0329-4d62-8328-0ff500fd42db"
Suggested code sample
First, you must create the webservice object:
OKMWebservices ws = OKMWebservicesFactory.newInstance(host);
Then you should log in using the method "login". You can access the "login" method from webservice object "ws" as shown below:
ws.login(user, password);
Once you are logged in with the web services, the session is kept in the webservice object. Then you can use the other API methods.
At this point you can use all the Note methods from "note" class as shown below:
ws.note.add("373bcdd0-c082-4e7b-addd-e10ef813946e", "the note text");
Methods
add
Description:
| Method | Return values | Description |
|---|---|---|
|
add(String nodeId, String text) |
Note |
Adds a note to a node and returns a Note object. |
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.add("f123a950-0329-4d62-8328-0ff500fd42db", "the note text");
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
get
Description:
| Method | Return values | Description |
|---|---|---|
|
get(String noteId) |
Note |
Retrieves the note. |
|
The noteId is a UUID. The Node object has a variable named path; in that case, the path contains a UUID. |
||
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.list("f123a950-0329-4d62-8328-0ff500fd42db");
if (notes.Count > 0)
{
System.Console.WriteLine(ws.note.get(notes[0].path));
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
delete
Description:
| Method | Return values | Description |
|---|---|---|
|
delete(String noteId) |
Note |
Deletes a note. |
|
The noteId is a UUID. The Node object has a variable named path; in that case, the path contains a UUID. |
||
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.list("f123a950-0329-4d62-8328-0ff500fd42db");
if (notes.Count > 0)
{
ws.note.delete(notes[0].path);
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
set
Description:
| Method | Return values | Description |
|---|---|---|
|
set(String noteId, String text) |
void |
Changes the note text. |
|
The noteId is a UUID. The Node object has a variable named path; in that case, the path contains a UUID. |
||
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.list("f123a950-0329-4d62-8328-0ff500fd42db");
if (notes.Count > 0)
{
ws.note.set(notes[0].path, "text modified");
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
list
Description:
| Method | Return values | Description |
|---|---|---|
|
list(String nodeId) |
List<Note> |
Retrieves a list of all notes for 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.list("f123a950-0329-4d62-8328-0ff500fd42db");
foreach (Note note in notes)
{
System.Console.WriteLine(note);
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
getNotesHistories
Description:
| Method | Return values | Description |
|---|---|---|
|
getNotesHistories(String nodeId) |
List<NoteHistory> |
Retrieves a list of all note histories 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());
}
}
}
}