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 called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Predictive weather mashup exercise

kkabak
1-Newbie

Predictive weather mashup exercise

Hello,

I am having trouble with the 2 services which get the weather information from open weather and yahoo weather site. I have implemented them just like in the tutorials, but I´m receiving the following error codes:

[context: com.thingworx.webservices.context.HttpExecutionContext@511e1e46][message: Execution error in service script [WeatherThing GetYahooWeatherInformation] : Wrapped org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog. Cause: Content is not allowed in prolog.]

[context: com.thingworx.webservices.context.HttpExecutionContext@6b492dd3][message: Execution error in service script [WeatherThing GetOpenWeatherForecastData] : Wrapped java.net.MalformedURLException: no protocol: api.openweathermap.org/data/2.5/weather?lat=39.0&lon=-111.0&units=imperial&type=accurate&mode=xml Cause: no protocol: api.openweathermap.org/data/2.5/weather?lat=39.0&lon=-111.0&units=imperial&type=accurate&mode=xml]

Can you please advise?

Two days ago the services were functional and I did not change anything.

Enclosed you can find the project files.

Thank you,

Kübra Kabak

3 REPLIES 3
vmihai
1-Newbie
(To:kkabak)

Hi,

The Open Weather API requires an API Key now. You can create yourself one at this website or you can use one that I have created for test  4abc8a3c9f101ccf9c7cfe7cbf3dfed7.

You need to append  &APPID=4abc8a3c9f101ccf9c7cfe7cbf3dfed7 (or your own api key value) at the end of the Open Weather URL in  the GetYahooWeatherInformation service at line 97

   var params = {

url: "http://api.openweathermap.org/data/2.5/weather?q="+cityName+"&type=accurate&mode=xml&APPID=4abc8a3c9f101ccf9c7cfe7cbf3dfed7"

/* STRING */,

timeout: 60 /* NUMBER */

};

And in the GetOpenWeatherForecastData; service at line 6

var params = {

url: "http://api.openweathermap.org/data/2.5/forecast?lat="+lat+"&lon="+long+"&units=imperial&type=accurate&mode=xml&APPID=4abc8a3c9f101ccf9c7cfe7cbf3dfed7" /* STRING */,

timeout: 160 /* NUMBER */

};

You shouldn't have any more errors now.

Veronica

vkunwar
1-Newbie
(To:vmihai)

I am facing the same problem. I have followed the above instruction but still I am facing the same problem.

I also facing problem in server authentication, I have my own username and password but sometime a pop up comes which require authentication.For that it doesn't take my username password.

can you please advice?

vmihai
1-Newbie
(To:vkunwar)

Hi Vinay,

Please note that yahoo weather api is no longer in service. Please check the post below for a working implementation of the OpenWeatherMap API service call :

https://community.thingworx.com/message/43348?et=watches.email.thread#43348

Let me know if you are in need of further assistance.

Veronica

Top Tags