Finding sentences by attribute value
Let's assume we want find a sentence based on its Module-ID. The endpoint to be used is <host>/Congree/api/AuthoringMemory/v1/Sentence
This endpoint has two optional parameters:
Parameter | Description |
---|---|
skip | Amount of the matched sentences to be skipped |
count | Amount of the matched sentences to be requested |
The body of the request contains the query as JSON object.
{ "Attributes": [ { "Name": "string", "Values": [ "string" ] } ] }
Property | Description |
---|---|
Attributes | An array of attributes used as the search criteria |
Name | The name of the attribute |
Values | An array of strings containing the values of the attribute |
If we want to search for a sentence who's Module-ID is 3333 the JSON object looks like this:
{ "Attributes": [ { "Name": "Module-ID", "Values": [ "3333" ] } ] }
A method to integrate everything looks like this:
public string FindSentencesByAttributes(string host, string token, string json){ var client = new RestClient(host + "/Congree/api/AuthoringMemory/v1/Sentences"); client.Timeout = -1; var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer " + token); request.AddHeader("Content-Type", "application/json"); var body = json; request.AddParameter("application/json", body, ParameterType.RequestBody); IRestResponse response = client.Execute(request); return response.Content; }
The reponse is a JSON object containing an array like this:
[ { "Id": 699534, "Xml": "My sentence.", "Attributes": [ { "Name": "Module-ID", "Values": [ "3333" ] } ] } ]
Property | Description |
---|---|
Id | The Id of the sentence in the Authoring Memory |
Xml | The sentence that was found |
Attributes | An array of all attributes belonging to the sentence. |
Name | The name of the attribute |
Values | An array of strings, i.e. attribute values, assigned to the attribute |