Is it possible to store String in Cumulocity?

Hi Folks,

My goal is to store some basic forms data related to device in cumulocity.

The data also contains String and Boolean form of data.

Is there is any way to store that data in Cumulocity.

If yes so, please tell the the complete steps.

Thanks,
Himanshu Agarwal

Hi Himanshu,

since Cumulocity uses a document based database you can store arbitrary fragments in a device. Devices are basically ManagedObjects that are managed via the Inventory API:

https://cumulocity.com/guides/reference/inventory/

You can also add properties using the Properties Library under Administration → Settings. Those can then be used e.g. in an Asset Properties Widget in the Cockpit Application.

Hope that helps.

Kind Regards,

Marco

I have store in events and and in text i have store complete json object as string, is it a right approach ?

The basic structure of an event has a few mandatory (source, type, time) fields. In addition there a some predefined fragments which are supported by the platform ootb. See the example below. There we have a location update which is interpreted by the platfrom using the c8y_Postition fragment.

{
	"source": {
    	"id":"2284329" },
    "type": "c8y_LocationUpdate",
    "text": "Location Update",
    "time": "{{current_C8Y_time}}",
    "c8y_Position": {
        "alt": 67,
        "lng": 10,594389,
        "lat": 50,80473
    }
}

Your can easily add your own fragment to that or create a complete new Event Type.

{
	"source": {
    	"id":"2284329" },
    "type": "c8y_MyStringEvent",
    "text": "MyString",
    "time": "{{current_C8Y_time}}",
    "myString": "This is my string"
}

Hope that helps!