Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
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 ?
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
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
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.