Reading a Property
You can write code to read a property of a Remote Thing on the ThingWorx Platform once the client successfully connects to it.
In the example below, the result of the request to read the name property of a Remote Thing is returned as an InfoTable, from which you extract the value. An InfoTable is a collection of one or more rows. A row can have multiple fields. Each field has a name and a base type. In this example, the name of the field is name and the base type is STRING. For more details about the InfoTable, refer to the section, InfoTables.

// Reading a property of a Remote Thing
///////////////////////////////////////////////////////////////

// Request a property from a Remote Thing on the ThingWorx Platform.
// To access the 'name' property of a Thing.
InfoTable result = client.readProperty(ThingworxEntityTypes.Things,
ThingName, "name", 10000);

// The result is returned as an InfoTable, so you must extract the value.
// For this example, use the getStringValue() method to retrieve the name.
String name = result.getFirstRow().getStringValue("name");

LOG.info("The name of the Thing {} is: {}", ThingName, name);

Was this helpful?