You need to sign in to do that
Don't have an account?
Nirmal Christopher 11
Easy Integration task need urgent help
Requirement :
In your Salesforce dev org, create a VF page where you can enter the name of a city. And on hitting "Fetch" button, it should fetch and display the current weather and 7 day forecast for that place.
Use Yahoo weather service API for getting the details.
https://developer.yahoo.com/weather/
this is the class I created
public class fetchweather{ public static HttpResponse makeGetCallout() { Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint('https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22nome%2C%20ak%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys'); request.setMethod('GET'); HttpResponse response = http.send(request); if (response.getStatusCode() == 200) { // Deserializes the JSON string into collections of primitive data types. Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody()); system.debug(results ); } return null;
}
I called this fetch weather method in the visual force page with a controllers method. I am getting error
System.CalloutException: Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22nome%2C%20ak%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys
Error is in expression '{!fetchdata}' in component <apex:commandButton> in page searchaccounts: Class.fetchweather.makeGetCallout: line 7, column 1
Class.searchAccounts.fetchdata: line 8, column 1
I know well that i am messed up with the end point URL.
Also I am not sure what to add in the remote site settings in the end point URL.
Can some one guide me how to do this??
In your Salesforce dev org, create a VF page where you can enter the name of a city. And on hitting "Fetch" button, it should fetch and display the current weather and 7 day forecast for that place.
Use Yahoo weather service API for getting the details.
https://developer.yahoo.com/weather/
this is the class I created
public class fetchweather{ public static HttpResponse makeGetCallout() { Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint('https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22nome%2C%20ak%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys'); request.setMethod('GET'); HttpResponse response = http.send(request); if (response.getStatusCode() == 200) { // Deserializes the JSON string into collections of primitive data types. Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody()); system.debug(results ); } return null;
}
I called this fetch weather method in the visual force page with a controllers method. I am getting error
System.CalloutException: Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22nome%2C%20ak%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys
Error is in expression '{!fetchdata}' in component <apex:commandButton> in page searchaccounts: Class.fetchweather.makeGetCallout: line 7, column 1
Class.searchAccounts.fetchdata: line 8, column 1
I know well that i am messed up with the end point URL.
Also I am not sure what to add in the remote site settings in the end point URL.
Can some one guide me how to do this??
Follow Steps:
Example :
String endpointurl = endpoint +'select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="Hyderabad, IN")';
Hope it helps you!!
Im getting this error in the visual force page where i am calling the web service call out method
System.CalloutException: no protocol: select+*+from+weather.forecast+where+woeid+in+%28select+woeid+from+geo.places%281%29+where+text%3D%22nome%2C+ak%22%29
Error is in expression '{!fetchdata}' in component <apex:commandButton> in page searchaccounts: Class.fetchweather.makeGetCallout: line 14, column 1
Class.searchAccounts.fetchdata: line 10, column 1
You done almost!!
Use this
request.setEndpoint(endpointurl );
Instead of yours request.setEndpoint(encodedURL);
and this is the code
I need help in parsing this kindly help
Hi,
I just did in my org with follow code. Try out in your org aswell. Hope it helps you !!