Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

Inhalt

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:

...

ParameterDescription
hostThe address of the server hosting Congree Authoring Server
filenameThe 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.
cultureThe code of the language the imported file is written in.
tokenThe Bearer token acquired during the authentication.

Searching for sentences in the Authoring Memory

Codeblock
languagec#
linenumberstrue
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);
}


ParameterDescription
hostThe address of the server hosting Congree Authoring Server
ruleSetThe name of the ruleset the sentence is checked with.
tokenThe Bearer token aquired acquired during the authentication.
sentenceA well-formed XML structure.