Skip to main content
1-Visitor
May 11, 2021
Solved

Response from thingworx Rest API call in c# program

  • May 11, 2021
  • 2 replies
  • 2043 views

Hi,

 

I using Thingworx Rest API call from c# program using with HttpClient and content-type = "application/json"

here with the url of getting thing property and response

https://tw_server.com/Thingworx/Things/Test_Thing/Properties/Custom_Property

{
"dataShape":{"fieldDefinitions":{"Custom_Property ":{"name":"Custom_Property ","description":"","baseType":"BOOLEAN","ordinal":2,"aspects":{"isPersistent":false,"isLogged":false,"dataChangeType":"VALUE","cacheTime":0.0}}}},
"rows":[{"Custom_Property ":true}]
}

 

I would like to get only property value as result or HttpResponseMessage, let me know if any way to ignore or not including the schema of property.

 

Thanks

Gopi

Best answer by VladimirRosu_116627

Hi,

 

This is absolutely possible, but the key here is to use HTTP header Accept= "text/csv". This will make the ThingWorx service to send you the shortest possible HTTP response.

An alternative is to just parse the JSON output, as suggested in another post.

It depends on what is the real issue: the fact that the response is too big, or the fact that it is not easy to parse it.

2 replies

17-Peridot
May 12, 2021

Hi @gvyakaranam,

 

Have you tried to use GetBooleanPropertyValue service API instead of property API? There is a service called GetBooleanPropertyValue in most things, you can test if this API can fulfill your business needs.

 

Thanks,

/Yoyo

 

 

1-Visitor
May 12, 2021

Hi @yhan ,

 

I was tried the suggested GetBooleanPropertyValue service, getting response with schema/fieldDefinitions.. mentioned below.

 

{"dataShape":{"fieldDefinitions":{"result":{"name":"result","description":"result","baseType":"BOOLEAN","ordinal":0,"aspects":{}}}},"rows":[{"result":false}]}

 

My expectation is that, response message should look like Propertyname:Value... No other details included in response .Example {"result":false}

19-Tanzanite
May 13, 2021

Hi,

 

This is absolutely possible, but the key here is to use HTTP header Accept= "text/csv". This will make the ThingWorx service to send you the shortest possible HTTP response.

An alternative is to just parse the JSON output, as suggested in another post.

It depends on what is the real issue: the fact that the response is too big, or the fact that it is not easy to parse it.

Community Manager
June 4, 2021

Hi @gvyakaranam.

 

If you feel your question has has been answered, please mark the appropriate response as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon