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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Question about API usage in the View Application

lsimpson1
1-Visitor

Question about API usage in the View Application

I am having an issue with an api call in Thingworx Studio. Using the preview option, everything works great. Whenever I opened the experience(after publishing) using the iPhone View App for Thingworx, the API call does not work. Is there some setting I am not configuring correctly? I know that on localhost it is my own machine that is hosting it so I just have to make sure firewall doesn't block it. How does that work with the Experience servers? I believe that the experience server isn't allowing my http request to go through. I am using the $http method to get data from the openweather api. I can post code if necessary, though I dont believe that will solve anything currently.

3 REPLIES 3

Which URL / API are you calling?

Is it localhost as you mentioned for the preview? I suppose you're using the fully qualified hostname, correct?

Is the host you're connecting to public to the internet?

This is the code in the function:

var text = $scope.app.view['Home'].wdg['textInput-1']['text'];

$http.get('http://api.openweathermap.org/data/2.5/weather?zip='+text+',us&APPID=(omitted)').then(function(response){

    var temperature = (9/5)*(response.data.main.temp - 273) + 32;

    $scope.app.view['Home'].wdg['gauge-2']['value'] = temperature;

    });

Works when running in preview on Thingworx studio. Does not work when running in the View App. The view app I have tried with Cellular data and the wifi network.

That's strange... it's a publicly accessible server, so the server shouldn't be an issue.

I would expect it to work in the app if it's working in the preview.

Are you able to retrieve data without the function in the URL, e.g. just from a RSS feed or something similar?

Announcements

Top Tags