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

How to get the Host Name of ThingWorx ?

pshirude
Regular Member

How to get the Host Name of ThingWorx ?

Is there any API using which I can get the host name of the ThingWorx ?

Ex: If TW Url is :  http://abcd:8080/Thingworx/Composer/index.html  .

how can I get the same ?

4 REPLIES 4

Re: How to get the Host Name of ThingWorx ?

Hello Prajakta, if you already have the full URL you can use a "Split" function (splits the full string to an array) and then you can reconstruct your desired string.

You can use the "Try it yourself" option for testing. JavaScript String split() Method

Re: How to get the Host Name of ThingWorx ?

Thanks for responding . But I need an API to get the full url itself..

* Reformed the question.

Re: How to get the Host Name of ThingWorx ?

Hello Prajakta,

You can use an expression widget for this, inside a Mashup (invisible at run time).

You can define whatever trigger you want for the Evaluate service(e.g. Mashup Loaded event) of the Expression, the output of the expression will be a string.

The actual expression to obtain the URL as you mentioned can be :  location.protocol+ "//" + location.host + "/Thingworx/" 

You can do whatever you want with this output -> use it in a service or display it somewhere. Furthermore, you can also use as an expression: location.href, to obtain the full URL of the Mashup where the user is currently on.

Please let me know if you need more information about this. I hope this was helpful.

Costin

Re: How to get the Host Name of ThingWorx ?

Thanks for the detailed information, Costin .

But looking for a way to fetch the host URL outside ThingWorx . Inside an app that uses data from ThingWorx.

Announcements

Check out the upcoming Expert Session: Understanding ThingWorx Navigate Licensing in Community "Customer Events" section.