Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
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
Solved! Go to Solution.
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.
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
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}
Yes, you are right. I tested in my environment and got the same result as yours, both using get property API and GetBooleanPropertyValue API.
After checking the Rest API document, it seems there is no direct way to get the response that only contains the "result: false".
Recommend you using Newtonsoft.Json library in C# to parse the JSON content in an easier way.
Thanks,
/Yoyo
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.
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