Skip to main content

2 replies

1-Visitor
April 27, 2016

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

pshirude5-Regular MemberAuthor
5-Regular Member
April 27, 2016

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

* Reformed the question.

5-Regular Member
April 27, 2016

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

pshirude5-Regular MemberAuthor
5-Regular Member
April 27, 2016

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.