Communication.makeWebRequest GET works in simulator, but gives 401 on Fenix7

I try to implement a widget for my Gamin Fenix 7. The task I struggle with is query data from an elastic server (TLS encryption with Lets Encrypt via a Traefik setup).

Query the data to test before with postman works fine:

Postman Test 2Postman Test 1

1. In the simulator without "Use device HTTPS Requirements" everything works.

Sim Network Response

2. In the simulator with "Use device HTTPS Requirements" it gives a 404 response.

I usually read in other posts, that this is due to self signed certificates. But with postman and with curl I do not get any issue here. Might be unrelated.

3. On the device it gives a 401 response. 

INVALID_HTTP_HEADER_FIELDS_IN_NETWORK_RESPONSE -401

API Level 1.0.0

Response contained invalid http header fields.

(from here)

My code looks like this

function onReceive(responseCode, data) {
   if (responseCode == 200) {
       System.println("\tRequest Successful\n\tData: " + data);
   }
   else {
       System.println("\tResponse: " + responseCode + "\n\tData: " + data);
   }   
}

function request() as Void {
    System.println("Request");

    var url = "https://user:[email protected]/_cluster/health?pretty";
    var param = {};
    var options = {
        :method => Communications.HTTP_REQUEST_METHOD_GET,
        :responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON ,
        :headers => {
            "Content-Type" => Communications.REQUEST_CONTENT_TYPE_JSON
        }
    };
    
    Communications.makeWebRequest(
        url, param, options, method(:onReceive)
    );
}

Any insights or suggestions here?

  • You want to first get things to work with "Use device HTTPS Requirements" checked.  Using "View HTTP Traffic" in the sim could help.

    Real devices are different in that GCM is your proxy, and there can be differences with Android and iOS based on what you are doing.

    With error codes, if they are negative, they are coming from CIQ/GCM.  Positive, the network, so indicating the sign is important.

    There is something with the signing or possibly a redirect is my guess, and things could be different based on Android or iOS.  Which are you using?

  • Thanks you so much for the fast reply!

    You want to first get things to work with "Use device HTTPS Requirements" checked.  Using "View HTTP Traffic" in the sim could help.

    Sure. Sound about right.

    In my original post I already screenshot the responded traffic. This is with "Use device HTTPS Requirements" when I get the 404 ( not -404) in the simulator.

    Real devices are different in that GCM is your proxy, and there can be differences with Android and iOS based on what you are doing.

    With error codes, if they are negative, they are coming from CIQ/GCM.  Positive, the network, so indicating the sign is important.

    What is GCM or CIQ?

    There is something with the signing or possibly a redirect is my guess, and things could be different based on Android or iOS.  Which are you using?

    Got it. My errors seems to be positive values, both in simulator and on the device. My phone is an Android (Huawei P30pro)

  • What is GCM or CIQ?

    GCM - Garmin Connect Mobile.  The Main Garmin app on your phone.

    CIQ - Connect IQ - your app and the part of CIQ that runs on your device

  • I will point out that the Garmin Connect app (on iOS and Android) hasn't had "Mobile" in its name for a very long time. This is understandable since the Garmin Connect mobile app has been the first class citizen for a long time (as opposed to Garmin Express or the Garmin Connect website.) It's like how we talk about our phones, not our "mobile phones".

    Even though the sub-forums for the iOS and Android apps still say "Garmin Connect Mobile", the app itself is listed as "Garmin Connect" in the Apple App Store and Google Play, and on your phone it's just called "Connect" (the app icon includes the text "Garmin" tho).

    Like if you never visited these forums or owned a Garmin 5 years ago, you would never know the app was once literally called "Garmin Connect Mobile".

    A lot of end users just refer to the Connect app (since that's what it's called on their phone.)

    So it's understandable if people may not know exactly what's meant if we say "GCM" without context.