Introduction
...
Getting an authentication token
To be able to use the functionality provided in the REST API it is necessary to obtain an authentication token that will be used in all of the requests dedicated to do linguistics checks.
In this section we will be creating a class that does all the work for us. The basic skeleton of the class is shown in the listing below:
...
Parameter | Description |
---|
host | The address of the server hosting Congree Authoring Server |
filename | The name of the file to be imported. The file must be either a valid file, e.g. the referenced DTD must be accessible or a well-formed XML file. |
culture | The code of the language the imported file is written in. |
token | The Bearer token acquired during the authentication. |
Searching for sentences in the Authoring Memory
Codeblock |
---|
language | c# |
---|
linenumbers | true |
---|
|
public void SearchSentence(string host, string ruleSet, string token, string sentence){
var client = new RestClient(host + "/Congree/api/AuthoringMemory/v1/Search");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "application/json");
request.AddHeader("Authorization", "Bearer " + token);
request.AddParameter("undefined", "{ \n \"Xml\": \" + sentence + "\",\n \"RuleSetName\": \" + ruleSet + "\" \n }", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
} |
Parameter | Description |
---|
host | The address of the server hosting Congree Authoring Server |
ruleSet | The name of the ruleset the sentence is checked with. |
token | The Bearer token aquired acquired during the authentication. |
sentence | A well-formed XML structure. |