Here is my code below :
using Toybox.Communications as Comm;
using Toybox.WatchUi as Ui;
using Toybox.Graphics;
using Toybox.System as Sys;
using Toybox.Position;
class Stocks
{
var symb;
var Bid;
}
class StocksView extends Ui.View {
hidden var mStocks = "";
//! Load your resources here
function onLayout(dc) {
mStocks = "Waiting for Stocks Data";
}
//! Restore the state of the app and prepare the view to be shown
function onShow() {
}
//! Update the view
function onUpdate(dc) {
dc.setColor(Graphics.COLOR_BLACK, Graphics.COLOR_WHITE);
dc.clear();
dc.drawText(dc.getWidth()/2, dc.getHeight()/2, Graphics.FONT_MEDIUM, mStocks, Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
Comm.makeJsonRequest("query.yahooapis.com/.../yql",
{"q"=>"select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22SRPT%22)%0A%09%09", "format"=>"json","diagnostics"=>"true","env"=>"store%3A%2F%2Fdatatables.org%2Falltableswithkeys"}, {}, method(:onReceive));
}
//! Called when this View is removed from the screen. Save the
//! state of your app here.
function onHide() {
}
function onReceive(responseCode, data)
{
if( responseCode == 200 )
{
var stocks = new Stocks();
weather.Symb = data["symbol"];
weather.Bid = data["Bid"];
Sys.println(weather.Symb);
Sys.println(weather.Bid);
}
else
{
mStocks = "Failed to load\nError: " + responseCode.toString();
}
Ui.requestUpdate();
}
}
I receive an error code 404 from the JSON request.
The original call to the api is
query.yahooapis.com/.../yql
Any help will be much appreciated :-)