Skip to main content
Apr 16, 2020 9:57 AM UTC
Solved

ThingTemplate - Get all properties of template using Java sdk

Hi,

I want to fetch the propertyDefinitions of a thingTemplate. I am calling GetMetadata service on the template - 

client.invokeService(RelationshipTypes.ThingworxEntityTypes.ThingTemplates, "MyTemplateName", "GetMetadata", new ValueCollection(), DEFAULT_TIMEOUT);

 This returns an empty propertyDefinitions infotable. The call works fine for entityType Things.

 

The rest call - GET <server>/Thingworx/ThingTemplates/MyTemplateName returns all the properties under path "effectiveShape/propertyDefinitions" in the response json.

 

How can I get the same using java sdk?

 

Regards,

Vaishnavee

Apr 17, 2020 8:38 AM UTC

I used an alternative api - 'GetInstanstanceMetadataAsJson' on ThingTemplate to get the metadata as a  JSONObject. This object is similar to the output of rest call GET <server>/Thingworx/ThingTemplates/MyTemplateName. 

3 replies

vaishnaveeAuthorAnswer
Apr 17, 2020 8:38 AM UTC

I used an alternative api - 'GetInstanstanceMetadataAsJson' on ThingTemplate to get the metadata as a  JSONObject. This object is similar to the output of rest call GET <server>/Thingworx/ThingTemplates/MyTemplateName. 

Apr 17, 2020 5:38 PM UTC

Hi @vaishnavee.

 

You might want to also look at GetPropertyDefinitions.

 

Regards.

 

--Sharon

Apr 22, 2020 12:03 PM UTC

Hi @slangley , Yes I tried that, returns _rows valueCollection of size zero. I dont know why it would do that. But only GetInstanceMetadataAsJSON worked for me.