Building an event request
Current version: 10.4
When the request configuration is complete, you can invoke the Build()
method to get the request object.
RequestResponse
var eventRequest = UTRequestBuilder.EventWithDefinitionId("01f8ffbf-d662-4a87-beee-413307055c48")
.AddCustomValues("key1", "value1")
.AddCustomValues("key2", "value2")
.Timestamp(DateTime.Now)
.Build();
When you build a request, you must observe the following rules:
-
You can define optional parameters in any order.
For example, the following two code samples are both correct requests:
RequestResponseUTRequestBuilder.SearchEvent("some keywords") .DefinitionId("01f8ffbf-d662-4a87-beee-413307055c48") .Timestamp(DateTime.Now) .AddCustomValues("key", "value") .Build();
RequestResponseUTRequestBuilder.SearchEvent("some keywords") .AddCustomValues("key", "value") .Timestamp(DateTime.Now) .DefinitionId("01f8ffbf-d662-4a87-beee-413307055c48") .Build();
-
The
Add…
methods accumulate values, so you must consider the order in which you invoke them.For example, the following request will contain two custom values:
RequestResponseUTRequestBuilder.EventWithDefinitionId("01f8ffbf-d662-4a87-beee-413307055c48") .AddCustomValues("key1", "value1") .AddCustomValues("key2", "value2") .Build();
-
Methods that do not accumulate values should only be invoked once.
An example of a correct request:
RequestResponseUTRequestBuilder.SearchEvent("some keywords") .DefinitionId("01f8ffbf-d662-4a87-beee-413307055c48") .Build();
An example of an incorrect request that throws an InvalidOperationException exception:
RequestResponseUTRequestBuilder.SearchEvent("some keywords") .DefinitionId("01f8ffbf-d662-4a87-beee-413307055c48") .DefinitionId("01f8ffbf-d662-4a87-beee-413307055c48") .Timestamp(DateTime.Now) .Timestamp(DateTime.Now) .Build();