Import with GateKeeper

Congree version 6.080 and higher support the import of XM files together with a quality check, i.e. the settings for gatekeeper settings apply when importing a file. The consequence is that only those sentences are being imported that meet the defined quality criteria.

The endpoint to be used is Congree/api/AuthoringMemory/v2/ImportXml?ruleSet=<ruleset>&documentId=<document>

<ruleset> is the name of the ruleset to be used to check the document to be imported.

<document> is an arbitrary string defining the identity of the document, i.e the file name or any other name.

 

public CongreeImportXmlResponse ImportXml(CongreeXmlImportRequest xml, string ruleSet, string documentId) { var request = new RestRequest("/Congree/api/AuthoringMemory/v2/ImportXml?ruleSet=" + ruleSet + "&documentId=" + documentId, Method.Post); request.AddHeader("Authorization", "Bearer " + this.token); request.AddHeader("Content-Type", "application/json"); var jsonmessage = JsonConvert.SerializeObject(xml); request.AddParameter("application/json", jsonmessage, ParameterType.RequestBody); var response = client.Execute(request); CongreeImportXmlResponse importResponse = JsonConvert.DeserializeObject<CongreeImportXmlResponse>(response.Content); return importResponse; }

est4

The return value used in the sample code above is defined like shown below:

public class CongreeImportXmlResponse { public string Id { get; set; } }

 

The Id value returned by the import method can be used to retrieve information about the status and the result.

As only one document can be imported at a time it is necessary to check the status, i.e the completeness of the import.

public CongreeTaskStatus GetTaskStatus(string id) { var request = new RestRequest("/Congree/api/Tasks/v1/Status/" + id, Method.Get); request.AddHeader("Authorization", "Bearer " + this.token); var response = client.Execute(request); CongreeTaskStatus taskStatus = JsonConvert.DeserializeObject<CongreeTaskStatus>(response.Content); return taskStatus; }

 

The return value is defined like this:

After the value of State is other than InProgress it is possible to retrieve information on the success, i.e. the number of imported sentences, information on failed imports etc. by retrieving this information as shown in the code sample below.

The class CongreeTaskResult is defined as shown below: