Import samples
Basic
We suggest executing the methods below for large imports or for simple creation cases.
These methods execute fewer steps in the background than what is described in Document samples and Folder samples. That means you will get better performance because less logic is executed on the server side.
Example of UUID:
- 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 the webservice object "ws" as shown below:
ws.login(user, password);
Once you are logged in with the webservice the session is kept in the webservice object. Then you can use the other API methods.
At this point you can use all the import methods from the "quickImport" class as shown below:
ws.quickImport.importDocument("1be884f4-5758-4985-94d1-f18bfe004db8", fileInfo);
Methods
importDocument
Description:
| Method | Return values | Description |
|---|---|---|
|
importDocument(String uuid, FileInfo fi) |
String |
Creates a new document and returns the UUID of the document. |
|
The value of the uuid parameter should be a folder or record node UUID. |
||
Example:
using System; using System.Collections.Generic;
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);
FileInfo fileInfo = new FileInfo("E:\\doc.docx");
String uuid = ws.quickImport.importDocument("22c1d190-f798-489d-b420-2008cb38705b", fileInfo);
System.Console.WriteLine("UUID ="+ uuid);
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
importDocument
Description:
| Method | Return values | Description |
|---|---|---|
|
importDocument(String uuid, DateTime? date, String author, FileInfo file) |
String |
Creates a new document and returns the UUID of the document. |
|
The value of the uuid parameter should be a folder or record node UUID. |
||
Example:
using System; using System.Collections.Generic;
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);
FileInfo fileInfo = new FileInfo("E:\\doc.docx");
String uuid = ws.quickImport.importDocument("22c1d190-f798-489d-b420-2008cb38705b", new DateTime(2024, 11, 20), "Test", fileInfo);
System.Console.WriteLine("UUID ="+ uuid);
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
importFolder
Description:
| Method | Return values | Description |
|---|---|---|
|
importFolder(String uuid, String name) |
String |
Creates a new folder and returns the UUID of the folder. |
|
The value of the uuid parameter should be a folder or record node UUID. |
||
Example:
using System; using System.Collections.Generic;
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);
String uuid = ws.quickImport.importFolder("22c1d190-f798-489d-b420-2008cb38705b", "Folder-Name");
System.Console.WriteLine("UUID ="+ uuid);
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
importFolder
Description:
| Method | Return values | Description |
|---|---|---|
|
importFolder(String uuid, String name, DateTime? date, String author) |
String |
Creates a new folder and returns the UUID of the folder. |
|
The value of the uuid parameter should be a folder or record node UUID. |
||
Example:
using System; using System.Collections.Generic;
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);
String uuid = ws.quickImport.importFolder("22c1d190-f798-489d-b420-2008cb38705b", "Folder-Name", new DateTime(2024, 11, 20), "Test");
System.Console.WriteLine("UUID ="+ uuid);
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
importMail
Description:
| Method | Return values | Description |
|---|---|---|
|
importMail(String uuid, FileInfo fi) |
String |
Creates a new mail and returns the UUID of the mail. |
|
The value of the uuid parameter should be a folder or record node UUID. |
||
Example:
using System; using System.Collections.Generic;
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);
FileInfo fileInfo = new FileInfo("E:\\test.eml");
String uuid = ws.quickImport.importMail("22c1d190-f798-489d-b420-2008cb38705b", fileInfo);
System.Console.WriteLine("UUID ="+ uuid);
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
importRecord
Description:
| Method | Return values | Description |
|---|---|---|
|
importRecord(String uuid, String name) |
String |
Creates a new record and returns the UUID of the record. |
|
The value of the uuid parameter should be a folder or record node UUID. |
||
Example:
using System; using System.Collections.Generic;
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);
String uuid = ws.quickImport.importRecord("22c1d190-f798-489d-b420-2008cb38705b", "Record-Name");
System.Console.WriteLine("UUID ="+ uuid);
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
importRecord
Description:
| Method | Return values | Description |
|---|---|---|
|
importRecord(String uuid, String name, DateTime? date, String author) |
String |
Creates a new record and returns the UUID of the record. |
|
The value of the uuid parameter should be a folder or record node UUID. |
||
Example:
using System; using System.Collections.Generic;
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);
String uuid = ws.quickImport.importRecord("22c1d190-f798-489d-b420-2008cb38705b", "Record-Name", new DateTime(2024, 11, 20), "Test");
System.Console.WriteLine("UUID ="+ uuid);
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}