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

How do I export the output in JSON format?

Highlighted
Level 12

How do I export the output in JSON format?

How do I export the output in JSON format?

 

We are developing the app[ANDROID APP and IOS APP] with ThingWorx.
I want to export some data from ThingWorx to JSON format.
I do not have a basic knowledge of JSON format.
How do I create a service to get data through the REST API?


Please help me..

Tags (4)
10 REPLIES 10

Re: How do I export the output in JSON format?

You can form a url format like,

<http/https:><host:port>/Thingworx/<entity collection>/<entity>/<characteristic collection>/<characteristic>?<query parameters>

 

Also refer: http://support.ptc.com/cs/help/thingworx_hc/thingworx_6.0_hc/index.jspx?id=thingworx10&action=show

 

Thanks.

 

Re: How do I export the output in JSON format?

Thanks

If i simply specify the output format of a ThingWorx service, would you use the REST API to get the value elsewhere?
Using like following code
result =
"{" +

    "name:" + me.name + "," +

    "value:" + me.property +

"}";

Re: How do I export the output in JSON format?

I make service

image 4.png

and execute service with api

image 5.png

but result is Invalid Request.. 

what's wrong?

Re: How do I export the output in JSON format?

Output Base Type?

Re: How do I export the output in JSON format?

Output base type is JSON

image 6.png

Re: How do I export the output in JSON format?

Try to use,

var params = {
	infoTableName: undefined /* STRING */
};
// table: INFOTABLE
var table = Resources["InfoTableFunctions"].CreateInfoTable(params)
table.AddField({name: "ColNameOne", baseType: "STRING"});
table.AddField({name: "ColNameTwo", baseType: "STRING"});
table.AddRow({
ColNameOne : "NAME_DATA",
ColNameTwo : "VALUE_DATA",
});

var params = {
	table: table /* INFOTABLE */
};
// table: JSON
var result = Resources["InfoTableFunctions"].ToJSON(params);

toJSON.JPG

Thanks.

Re: How do I export the output in JSON format?

now result is showing like pictures

image 2.pngimage 3.png

and i test API following URL

image 1.png

but REST API return invalid request

request API URL isn't wrong?

Re: How do I export the output in JSON format?

It returns the ThingWorx service definition instead of JSON when attempting with the following URL:

image 2.png
Can not get value in the following general JSON form?
{
         "name": ThingName,
         "value": PropertyValue
}

Re: How do I export the output in JSON format?

Please test with Postman.