Last date modified: 2025-Jun-17
Import images
You can use the Import Service API to add images to Relativity programmatically.
On GitHub, you can find can comprehensive samples illustrating how to import native documents, images, objects, and productions. For additional code samples, see the Import Service API samples repository.
Create import job
The following code sample illustrates how to create an import job entity in a particular workspace. The job is defined by an unique ID generated by the user and provided in the request.
1
2
3
4
5
6
curl -X POST 'https://relativity-host/Relativity.REST/api/import-service/v1/workspaces/10000/import-jobs/4c4215bf-d8a3-48d4-a3e0-3a40428415e7/'
-H 'X-CSRF-Header: -'
-d '{
"applicationName": "simpleImportImages",
"correlationID": "img0r22ati0n_ID"
}'
Create import job configuration
The following code sample illustrates how to configure existing import jobs by defining sets of significant parameters; import type, mode, and field mappings.
1
2
3
curl -X POST \'https://relativity-host/Relativity.REST/api/import-service/v1/workspaces/10000/import-jobs/4c4215bf-d8a3-48d4-a3e0-3a40428415e7/documents-configurations/'
-H 'X-CSRF-Header: -'
-d "$importSettings"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"importSettings": {
"Overlay":null,
"Native":null,
"Image":
{
"PageNumbering": 1,
"ProductionID": null,
"LoadExtractedText": false,
"FileType": 0
}
"Fields": null,
"Folder": null
}
}'
1
2
3
4
5
6
7
8
9
10
ImportDocumentSettings importSettings = ImportDocumentSettingsBuilder.Create()
.WithAppendMode()
.WithoutNatives()
.WithImages(i => i
.WithAutoNumberImages()
.WithoutProduction()
.WithoutExtractedText()
.WithFileTypeAutoDetection())
.WithoutFieldsMapped()
.WithoutFolders();
Add data source
The following code sample illustrates how to create data source entities for a particular import job. It represents the configuration that corresponds to a dataset being imported. Data source is identified by an unique ID generated by the user and provided in the request. Data source configuration includes the path to the load file and other significant parameters telling how the data in the load file will be read and interpreted by the system.
You can add many data sources to the same import job. Data sources can be added both before and after a job is started, users can add additional sources to running import jobs.
1
2
3
4
5
curl -X POST 'https://relativity-host/Relativity.REST/api/import-service/v1/workspaces/10000/import-jobs/4c4215bf-d8a3-48d4-a3e0-3a40428415e7/sources/0cb922a2-8df4-42fd-9429-c241410a0002'
-H 'X-CSRF-Header: -' \
-H 'Content-Type: application/json'
-d "$dataSourceSettingsJson"
}'
1
2
3
4
5
6
7
8
9
10
11
{
"dataSourceSettings": {
"Path": "C:\\DefaultFileRepository\\samples\\opticon_file.opt",
"FirstLineContainsColumnNames": false,
"StartLine": 0;
"EndOfLine" = 0
Encoding" = null
"CultureInfo" : null,
"Type": 1
}
}'
1
2
3
4
5
6
7
DataSourceSettings dataSourceSettings = DataSourceSettingsBuilder.Create()
.ForOpticonFile("C:\\DefaultFileRepository\\samples\\opticon_file.opt")
.WithDefaultDelimitersForOpticonFile()
.WithEndOfLineForWindows()
.WithStartFromBeginning()
.WithDefaultEncoding()
.WithDefaultCultureInfo();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
DataSourceSettings dataSourceSettings = new DataSourceSettings
{
Type = DataSourceType.Opticon,
Path = "C:\\DefaultFileRepository\\samples\\opticon_file.opt",
NewLineDelimiter = default,
ColumnDelimiter = default,
QuoteDelimiter = default,
MultiValueDelimiter = default,
NestedValueDelimiter = default,
Encoding = null,
CultureInfo = null,
EndOfLine = DataSourceEndOfLine.Windows,
FirstLineContainsColumnNames = false,
StartLine = 0,
};
Begin import job
The following code sample illustrates how to start an import job using begin. Begin allows you to schedule importing data to a workspace. A begun job does not mean that data is instantly imported. However, data sources are added to the queue and scheduled. The import job state or data source state shows the current stage of the import job.
1
2
3
curl -X POST 'https://relativity-host/Relativity.REST/api/import-service/v1/workspaces/10000/import-jobs/4c4215bf-d8a3-48d4-a3e0-3a40428415e7/begin/'
-H 'X-CSRF-Header: -'
-d ''
End import job
The following code sample illustrates how to end an import job that has already started. It is highly recommended to add the code if no more data sources are planned to be added. All data sources added to the job before the end request is sent will be imported.