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

Export data from Valuestream/DataTable programmatically

SOLVED
Aquamarine

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.

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Export data from Valuestream/DataTable programmatically

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 */
});

View solution in original post

8 REPLIES 8

Re: Export data from Valuestream/DataTable programmatically

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 */
});

View solution in original post

Re: Export data from Valuestream/DataTable programmatically

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

Re: Export data from Valuestream/DataTable programmatically

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

Re: Export data from Valuestream/DataTable programmatically

Big thank you :)

 

And is there any way to detect that the export is finished?

Re: Export data from Valuestream/DataTable programmatically

You will need to query Log Entries there's a message saying it.

Re: Export data from Valuestream/DataTable programmatically

Hmm parsing log entries seems not much fun.

 

I have a next problem. The security log says: "ApplicationKey Is Not Allowed As A URL Parameter." (error) and the ApplicationLog says: "The REST API was accessed using an appKey url parameter with a valid keyId" (warning).

Re: Export data from Valuestream/DataTable programmatically

Yes it's "fun" I mean you have a snippet to query Log Entries ;)

 

var result = Logs["The_desired_log"].QueryLogEntries...

Re: Export data from Valuestream/DataTable programmatically

About the warning/error you are getting it's normal, as starting ( I don't remember the TW version ) this isn't allowed - it's a security risk - and you will have to enable it on PlatformSubsystem "Allow Application Key as URL Parameter"

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________