public void StoreXml(string host, string filename, string culture, string token){ var client = new RestClient(host + "/Congree/api/AuthoringMemory/v1/ImportXml?lang=" + culture); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "multipart/form-data"); request.AddHeader("Authorization", "Bearer " + token); request.AddHeader("Content-Type", "multipart/form-data"); request.AlwaysMultipartFormData = true; request.AddFile("file", filename, ParameterType.RequestBody); IRestResponse response = client.Execute(request); }
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. |
While importing documents into the Authoring Memory it is possible to assign attributes to the import. Those attributes can later be used for different purpose like filtering them by certain usage areas or identifying them by an ID coming from a CMS.
To add attributes you just need to add another parameter to the request specifying the attribute(s) you want to assign. The general syntax looks like shown below:
[ { "Name": [attribute name], "Values": [ [attribute value] ] } ]
Property | Description |
---|---|
attribute name | The name of the attribute you want to assign. |
attribute value | A string array containg the value(s) of the attribute |
Let's assume you want to assign the attribute "usageArea" with the values "Marketing" and "TechPubs" and the attribute "CMS_Id". The JSON structure will look like this:
[ { "Name": "usageArea", "Values": [ "Marketing", "TechPubs" ] }, { "Name": "CMS_Id", "Values": [ "Id001" ] } ]
To store the attributes along with the XML file you need to add a new request parameter to the code shown above (StoreXML).
public void StoreXml(string host, string filename, string culture, string token){ var client = new RestClient(host + "/Congree/api/AuthoringMemory/v1/ImportXml?lang=" + culture); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "multipart/form-data"); request.AddHeader("Authorization", "Bearer " + token); request.AddHeader("Content-Type", "multipart/form-data"); request.AlwaysMultipartFormData = true; request.AddFile("file", filename, ParameterType.RequestBody); request.AddParameter("attributes", "[ { "Name": "usageArea", "Values": ["Marketing","TechPubs"]},{ "Name": "CMS_Id","Values": ["Id001"]}]"); IRestResponse response = client.Execute(request); }
Searching for sentences in the Authoring Memory
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 acquired during the authentication. |
sentence | A well-formed XML structure. |
The request returns a JSON object that is described in the Reference Manual.