Hello,
When I try to make a webRequest in a widget
the code:
using Toybox.System;
using Toybox.Communications;
using Toybox.Lang;
class JsonTransactionTest {
function onReceiveTest(responseCode as Lang.Number, data as Null or Lang.Dictionary or Lang.String) as Void{
if (responseCode == 204) {
System.println("Request Successful");
} else {
System.println("Response: " + responseCode);
}
}
function makeRequestLocalHost() as Void {
var url = "http://192.168.1.117:8080/position";
var latitudePosition= 0;
var longitudePosition= 0;
var params = {
"latitude" => latitudePosition,
"longitude" => longitudePosition,
};
var options = {
:method => Communications.HTTP_REQUEST_METHOD_GET,
:headers => {
"Content-Type" => Communications.REQUEST_CONTENT_TYPE_URL_ENCODED
},
:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON
};
Communications.makeWebRequest(url, params, options, method(:onReceiveTest));
System.println("makeRequest() done");
}
}
I get this on the debug console:
Error: Invalid Value Details: Failed invoking <symbol> Stack: - makeRequestLocalHost() at C:\Users\user\Documents\garmin\widget12\source\widgetHttp.mc:32 0x100000a6 - onTap() at C:\Users\user\Documents\garmin\widget12\source\widgetInputTest.mc:18 0x100002ba - handleEvent() at 704b03c0.mb:1265 0x30002a32 - handleEvent() at 704b03c0.mb:1474 0x30002cf9
I call the method by doing a onTap.
I still have the error if I make a https request