Events¶
V1_EventsAPI1 actions
Write an event. Read the warning on the Events overview page before you use it: events written here do not pass the default provider filter.
Every call in this group
- Method
POSTtohttps://{tenant}/api/{Group}/{Action}, also for reads. - Header
TempIdentityToken: <token>. Create tokens in Configuration > Services > API Access. - Success HTTP 200 with
{ "Success": true, "MessageKey": ..., "Data": ... }. Always checkSuccess. - Failure HTTP 412 with
{ "Success": false, "Messages": [ { "MessageKey": ... } ] }. The spec lists failures as 400; the server sends 412. HTTP 401 means the token or its features; HTTP 422 means the body does not match the model. - C# samples Use the generated client
KL.APIClient. Generate the client from your tenant's spec (how). A non-200 status throwsKL.APIClient.Client.ApiException. - Guides API introduction, Authentication
Actions¶
| Action | Summary |
|---|---|
| WriteEvent | Adds an event to the Monitor log with the provided properties and scopes. |
WriteEvent¶
POST/api/V1_EventsAPI/WriteEvent
Adds an event to the Monitor log with the provided properties and scopes.
- Token feature Write Events
- Content type application/json
Request¶
An object containing a dicitonary of event properties and a list of scopes.
Schema: EventDTO. An object containing details about a loggable event
| Field | Type | Description |
|---|---|---|
User |
string | |
Properties |
object | A dictionary of properties for this event |
Scopes |
array of string | The ordered list of scopes for this event |
Response¶
Returns indication of successful event write
Returns object.
Example¶
using KL.APIClient.Api;
using KL.APIClient.Client;
using KL.APIClient.Model;
var config = new Configuration { BasePath = "https://yourcompany.knowledgelake.io/api" };
config.AddApiKey("TempIdentityToken", Environment.GetEnvironmentVariable("KL_TOKEN"));
var api = new V1EventsAPIApi(config);
var response = await api.V1EventsAPIControllerWriteEventAsync(new EventDTO
{
User = "string",
Properties = new Dictionary<string, string>(),
Scopes = new List<string> { "string" },
});
if (response.Success != true) throw new Exception(response.MessageKey);
Console.WriteLine(response);
$body = @'
{
"User": "string",
"Properties": {},
"Scopes": [
"string"
]
}
'@
$r = Invoke-RestMethod -Method Post -Uri "https://yourcompany.knowledgelake.io/api/V1_EventsAPI/WriteEvent" `
-Headers @{ TempIdentityToken = $env:KL_TOKEN } `
-ContentType "application/json" -Body $body
if (-not $r.Success) { throw $r.MessageKey }
$r.Data
import os, requests
r = requests.post("https://yourcompany.knowledgelake.io/api/V1_EventsAPI/WriteEvent",
headers={"TempIdentityToken": os.environ["KL_TOKEN"]},
json={
"User": "string",
"Properties": {},
"Scopes": [
"string"
]
})
data = r.json()
if not data.get("Success"):
raise RuntimeError(data.get("MessageKey") or data.get("Messages"))
print(data["Data"])
const r = await fetch("https://yourcompany.knowledgelake.io/api/V1_EventsAPI/WriteEvent", {
method: "POST",
headers: { "TempIdentityToken": process.env.KL_TOKEN, "Content-Type": "application/json" },
body: JSON.stringify({
"User": "string",
"Properties": {},
"Scopes": [
"string"
]
})
});
const data = await r.json();
if (!data.Success) throw new Error(data.MessageKey ?? JSON.stringify(data.Messages));
console.log(data.Data);