The entire process of storing reports is done within a session. That's why any reporting process begins with acquiring a session id.
Codeblock |
---|
language | c# |
---|
title | Getting a session id |
---|
linenumbers | true |
---|
|
public string GetSessionId(string filename, string ruleSet)
{
var client = new RestClient(this.serverUrl + "/congree/api/Linguistic/Reporting/v1/Sessions");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer " + this.token);
request.AddParameter("application/json", "{\n\"DocumentName\": \"" + filename + "\",\n\"RuleSet\": \"" + ruleSet + "\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
SessionIdObject id = JsonConvert.DeserializeObject<SessionIdObject>(response.Content);
return id.SessionId;
} |
Parameter | Description |
---|
filename | The name of the file that was checked. |
ruleSet | The name of the rule set that was used to check the document. |
The sample above uses a helper class that is being used as the result of the request. The code is shown below.
Codeblock |
---|
language | c# |
---|
linenumbers | true |
---|
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Congree
{
public class SessionIdObject
{
public string SessionId { get; set; }
}
}
|