Under Review
over 1 year ago

Communications.makeWebRequest now failing to get json file in simulator with 404 error

I have been downloading json files in the simulator for many years which I use to setup parameters so I can test my code on the multitude of Garmin devices.  Recently I have started getting a 404 error response when trying to do this in the simulator.  I have not tried it on my device as yet.

My code has not changed and essentially it is this:

        var options = { :method => Communications.HTTP_REQUEST_METHOD_GET,
                        :headers => { "Content-Type" => Communications.REQUEST_CONTENT_TYPE_JSON },
                        :responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON };
        Communications.makeWebRequest(myUrl, {}, options, method(:onReceive));

    function onReceive(responseCode, jsonData) {
        haveResponse = true;
        if (responseCode == 200) {
            if (jsonData instanceof Dictionary) {
                System.println("KTV: onReceive: loading json file workout dictionary");
            } else {
                System.println("KTV: onReceive: Error in json file: is not a proper workout definition");
                haveWorkout = false;
            }
        } else {
            haveWorkout = false;
            System.println("KTV: Failed to load workout from url provided in settings\nError: " + responseCode.toString());

I know that the URL is a json file and when I open it on Firefox it reports it as being Content-Type application.json

I can open the URL from my LAN and from the web on other devices and I have copied and pasted the URL from those devices into the App Settings Editor so there is no typo involved.

I am getting this output from the code:

KTV: Failed to load workout from url provided in settings
Error: 404

I am running Eclipse IDE for Java Developers (includes Incubating components)
Version: 2020-06 (4.16.0)
Build id: 20200615-1200

on MacOS Big Sur;

and Connect IQ Device Simulator 4.0.6 which is of course the SDK version.