Skip to main content
1-Visitor
December 21, 2015
Solved

How to get remote property definition.

  • December 21, 2015
  • 2 replies
  • 2455 views

Hi All,

I am trying to get the remote properties of a remote thing. I want to do it programmatically (using services.). To see what are the properties are available at remote thing. Then i can bind or unbind it as per requirement. We can do it in composer by manage binding -> remote tab. I want to see remote properties using service.

Thanks in advance!!!

Regards,

Vishal Vaidya

Best answer by mattl1

You can use GetRemoteMetadata:

// result: JSON

Things[ThingName].GetRemoteMetadata();

ThingName ​should have a Thing Template of 'RemoteThing' in order to see the GetRemoteMetadata service. The service returns JSON, which can then be iterated through:


var remoteData = Things[ThingName].GetRemoteMetadata();

var propertyDefinitions = remoteData.propertyDefinitions;

for(var i in propertyDefinitions)

{

    propertyDefinitions.name;     //Available remote property name

}

2 replies

mattl11-VisitorAnswer
1-Visitor
December 21, 2015

You can use GetRemoteMetadata:

// result: JSON

Things[ThingName].GetRemoteMetadata();

ThingName ​should have a Thing Template of 'RemoteThing' in order to see the GetRemoteMetadata service. The service returns JSON, which can then be iterated through:


var remoteData = Things[ThingName].GetRemoteMetadata();

var propertyDefinitions = remoteData.propertyDefinitions;

for(var i in propertyDefinitions)

{

    propertyDefinitions.name;     //Available remote property name

}

vvaidya1-VisitorAuthor
1-Visitor
December 22, 2015

Thank a lot Matt Lang​. This exactly i was looking for.

Thanks again!

Vishal Vaidya