Ivajlo Iliev
Ivajlo Iliev

Reputation: 463

Is it possible to filter events by custom properties in Cumulocity

I am inserting events with custom properties in Cumulocity. Is there any way to filter events by there custom properties?

Upvotes: 0

Views: 154

Answers (2)

Surajit Das
Surajit Das

Reputation: 81

{{url}}/event/events?fragmentType=custom_key&fragmentValue=xyz

Upvotes: 1

Jorge
Jorge

Reputation: 238

Depends on what do you mean by "filter events by custom properties". If you mean filter by a custom "key" inside the event like:

{
  "text" : "my custom event",
  "type" : "event type",
  "id" : "c8yId",
  "time" : "time",
  "custom_key" : "specific value"
}

You can use the Cumulocity API using the "fragmentType" in the request. You can do this by sending the "custom_key" as a filter like so:

GET /event/events?fragmentType="custom_key" HTTP/1.1
Host: tenant.cumulocity.com
Authorization: Basic .....

That will return all event with that specific key.

In the other hand, if you want to filter by a custom "key" with a "specific value", you can do this by creating a simple microservice that does that for you. In the microservice you send the same request (above), then filter the result by comparing the value of "custom_key" with the value you want to filter and then send the events matched as a result.

Hope this help!

Upvotes: 1

Related Questions