return 404 when using Communications.makeImageRequest with this url https://tile.openstreetmap.org/15/16924/11672.png

Hello.

I try to get an url with an application and get 404.

It's not possible to view Http traffic logs  and I don't know why I cant' see it.

When I move this picture to my web server   https://riedid74.fr/15/16924/11672.png

all is good and I display the picture correctly  on the watch.

Is it a restriction to get a picture from  tile.openstreetmap.org

thanks

#######################################################

the code is

        var options = {
           // :palette => [ Graphics.COLOR_WHITE,                     // set the palette
 
           //              Graphics.COLOR_BLACK ],
            :maxWidth => 256,
            :maxHeight => 256,
            :method => Communications.HTTP_REQUEST_METHOD_PUT as Communications.HttpRequestMethod,
            :responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_TEXT_PLAIN as Communications.HttpResponseContentType,
            :dithering => Communications.IMAGE_DITHERING_FLOYD_STEINBERG,
            :packingFormat => Communications.PACKING_FORMAT_PNG
        };

        // Make the image request
        Communications.makeImageRequest(url, parameters, options, self.method(:onReceiveImage));
function onReceiveImage(responseCode, data) {

      System.println("function onReceiveImage  response="+ responseCode+ "\n"+data);    
         if (responseCode == 200) {
            image = data;
        } else {
            image = null;
            image = data;
        }

}
 
  • i will check on this device tomorrow 

    thanks for your action 

    Didier 

  • I check again my code  and have 404 again

    I use SDK 743 but in 8.1 it's same.

    function GetPicture(){
     
     URLOPEN="">tile.openstreetmap.org/.../11673.png";
            System.println("URLOPEN="+URLOPEN);
     
            var parameters = null;                                  // set the parameters
            var options = {
     
                :maxWidth => 170,
                :maxHeight => 170,
                :dithering => Communications.IMAGE_DITHERING_NONE,
                :packingFormat => Communications.PACKING_FORMAT_PNG
            };
     
            // Make the image request
            Communications.makeImageRequest(URLOPEN, parameters, options, method(:onReceiveImage));
     
                         
    }

    function onReceiveImage(responseCode, data) {

          System.println("function onReceiveImage  response="+ responseCode+ "\n"+data);    
             if (responseCode == 200) {
                image = data;
            } else {
                image = null;
         
            }

    }


    in terminal logging

    Call GetPicture

    URLOPEN=tile.openstreetmap.org/.../11673.png

    function onReceiveImage response=404 null


    When I call my own URL on my webserver all is good with same code

  • with which devices you tried? Which SDK?

  • with sdk 8.1 or 7.4.3  same issue

    with device F6X, F8, F7X same isue 

    @AndyJ713, in your test, are you sure you get url on openstreetmap or on my webserveur

    Perhaps openstreetmap verify user agent. in the header ??

    If I get https://tile.openstreetmap.org/15/16924/11673.png I have 404 code 

    If I get https://riedid74.fr/15/16924/11673.png (the download picture) I have 200 ode and I display the picture on the watch for all devices F3, F6, F7 F8

  • The short answer is you are being told it is a 404 error when in fact it is a 403 error.

    The long answer: To make the image round with a transparent background I have to use my own nginx server with PHP since setFill with images doesn't work pre CIQ 4. The benefit of that is I can get more information from PHP  when things don't work right, and what I can say is that when PHP tries to get the "tile" image it gets a 403 from the server:

    FastCGI sent in stderr: "PHP message: PHP Warning:  file_get_contents(https://tile.openstreetmap.org/15/16924/11673.png): Failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden

    The upside of this for me is that when this happens PHP returns error 500 to the watch, which I do see as such oddly enough:

    Background: 2025-03-18,05:22:45, rqWI _url https://web5.not-real-name.com/g1/ci/4234_a3d1cb8095a2dae939eb51dac71b8bffd0cd3917_150393265_0/a
    Background: 2025-03-18,05:22:45, rqWI _params {u=>https://tile.openstreetmap.org/15/16924/11673.png}
    Background: 2025-03-18,05:22:45, rqWI _wPic {symbol (8389661)=>170, symbol (8391907)=>2, symbol (8389694)=>2, symbol (8389657)=>170}
    Background: 2025-03-18,05:22:45, onRWI response 500, data null
    

    This tells me that I need to update my php script to handle bad data and a bad response more gracefully, but that's my problem.

    When it works it looks like this:

    Background: 2025-03-18,05:27:48, rqWI _url https://web5.not-real-name.com/g1/ci/4234_a3d1cb8095a2dae939eb51dac71b8bffd0cd3917_150696359_0/a
    Background: 2025-03-18,05:27:48, rqWI _params {u=>https://riedid74.fr/15/16924/11673.png}
    Background: 2025-03-18,05:27:48, rqWI _wPic {symbol (8389661)=>170, symbol (8391907)=>2, symbol (8389694)=>2, symbol (8389657)=>170}
    Background: 2025-03-18,05:27:48, onRWI response 200, data Bitmap 170 x 170
    

    The challenge with garmin and images is that there can be multiple places along the way you can get errors. Also, if you are using a watchface you have to do it in the background which adds another challenge because it doesn't work for MIP devices with CIQ 4 and later.

  • in my sample it's an app so i can use for all devices 

  • The other challenge if you didn't already learn it from other posts in the forum is that makeImageRequest does not go to the image source web server directly like makeWebRequest does. Instead it goes through a garmin proxy which does image processing like scaling and dithering for the destination palette before sending it to the watch. Because of this, you will not always see initial error from the source web server. In this particular case, when I tried the "tile" URL it worked in my web browser and with curl, but not PHP. Maybe there is a user-agent check or something similar which is causing different behavior with different clients. 

  • OK  

    Do you have the same behavior in the http traffic log? For me I don't see anything, whereas when I use makeWebRequest I see the request. I can't understand why when the image is on my server it works and not directly on the OpenStreetMap server.

  • I tried this:

    curl -v -o test.png https://tile.openstreetmap.org/15/16924/11673.png

    and got this:

    > GET /15/16924/11673.png HTTP/1.1
    > Host: tile.openstreetmap.org
    > User-Agent: curl/8.4.0
    > Accept: */*
    >
    { [5 bytes data]
    * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
    { [201 bytes data]
    < HTTP/1.1 200 OK
    < Connection: keep-alive
    < Content-Length: 16519
    < Server: Apache/2.4.62 (Ubuntu)
    

    I tried this:

    curl -v -o test.png -A "Java/21.0.3" https://tile.openstreetmap.org/15/16924/11673.png

    and got this:

    > GET /15/16924/11673.png HTTP/1.1
    > Host: tile.openstreetmap.org
    > User-Agent: Java/21.0.3
    > Accept: */*
    >
    { [5 bytes data]
    * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
    { [201 bytes data]
      0     0    0     0    0     0      0      0 --:--:--  0:00:06 --:--:--     0< HTTP/1.1 403 Forbidden
    < Connection: close
    < Content-Length: 71
    < Server: Varnish
    < Retry-After: 0
    < Accept-Ranges: bytes
    < Date: Tue, 18 Mar 2025 16:04:43 GMT
    < Via: 1.1 varnish
    < X-Served-By: cache-toj-leto2350024-TOJ
    < X-Cache: MISS
    < X-Cache-Hits: 0
    < X-Timer: S1742313884.735384,VS0,VE0
    <
    { [5 bytes data]
    100    71  100    71    0     0      7      0  0:00:10  0:00:09  0:00:01    18
    * Closing connection
    

    Openstreetmap just does not like the garmin server using Java.

  • What happens if you pass the user agent header as well? Does the garmin server pass it?