Skip to main content
1-Visitor
June 4, 2018
Solved

Export data from Valuestream/DataTable programmatically

Hi,

 

I try to create a thing that export things and data via "ThingWorx Git Extension" automatically via scheduler (for example every night). Exporting things is not a problem. But how can I programmatically export data? Is there any service or ressource that can do this?

 

Thanks in advance.

1-Visitor
June 4, 2018

You can trigger DataExport as if you where on the Coposer:

var exportAllDataURL = "https://YOUR_SERVER/Thingworx/DataExporter/?Accept=application/octet-stream&repositoryName=SystemRepository&path=/Platform.Data&appKey="+AN_ADMINISTRATOR_API_KEY_THERES_A_SECURITY_RISK_HERE_BUT_THE_PETITION_ITS_DONE_ON_THE_SAME_SERVER+"&_="+Math.random();
var result = Resources["ContentLoaderFunctions"].GetText({
	proxyScheme: undefined /* STRING */,
	headers: undefined /* JSON */,
	ignoreSSLErrors: true ,
	useNTLM: undefined /* BOOLEAN */,
	workstation: undefined /* STRING */,
	useProxy: undefined /* BOOLEAN */,
	withCookies: undefined /* BOOLEAN */,
	proxyHost: undefined /* STRING */,
	url: exportAllDataURL ,
	timeout: undefined /* NUMBER */,
	proxyPort: undefined /* INTEGER */,
	password: undefined /* STRING */,
	domain: undefined /* STRING */,
	username: undefined /* STRING */
});

8 replies

1-Visitor
June 4, 2018

You can trigger DataExport as if you where on the Coposer:

var exportAllDataURL = "https://YOUR_SERVER/Thingworx/DataExporter/?Accept=application/octet-stream&repositoryName=SystemRepository&path=/Platform.Data&appKey="+AN_ADMINISTRATOR_API_KEY_THERES_A_SECURITY_RISK_HERE_BUT_THE_PETITION_ITS_DONE_ON_THE_SAME_SERVER+"&_="+Math.random();
var result = Resources["ContentLoaderFunctions"].GetText({
	proxyScheme: undefined /* STRING */,
	headers: undefined /* JSON */,
	ignoreSSLErrors: true ,
	useNTLM: undefined /* BOOLEAN */,
	workstation: undefined /* STRING */,
	useProxy: undefined /* BOOLEAN */,
	withCookies: undefined /* BOOLEAN */,
	proxyHost: undefined /* STRING */,
	url: exportAllDataURL ,
	timeout: undefined /* NUMBER */,
	proxyPort: undefined /* INTEGER */,
	password: undefined /* STRING */,
	domain: undefined /* STRING */,
	username: undefined /* STRING */
});
Translate
drichter1-VisitorAuthor
1-Visitor
June 8, 2018

Nice. This seems to work. For which reason you put Math.random() at the end?

Translate
1-Visitor
June 8, 2018

Usually it's done to prevent cache/proxy responses.

Translate