cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Response from thingworx Rest API call in c# program

gvyakaranam
11-Garnet

Response from thingworx Rest API call in c# program

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

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

5 REPLIES 5
yhan
17-Peridot
(To:gvyakaranam)

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}

yhan
17-Peridot
(To:gvyakaranam)

Yes, you are right. I tested in my environment and got the same result as yours, both using get property API and GetBooleanPropertyValue API.

Capture.PNG

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.

slangley
23-Emerald II
(To:gvyakaranam)

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

Top Tags