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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

How to get the Host Name of ThingWorx ?

pshirude
5-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

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

pshirude
5-Regular Member
(To:ptc-5082906)

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

* Reformed the question.

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

pshirude
5-Regular Member
(To:costinb)

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.

Top Tags