Search code examples
javascriptesri

ESRI Print Task (export web map) returns 500


I tried to export web map(Esri) with print task service. it works in localhost and in staging.xxx.com(http) too.But in preview.xxx.com(https) , it throws the error 500: Error performing execute operation.

{"error":{"code":500,"message":"Error performing execute operation","details":[]}}

I can't figure out what's happening , staging uses http and preview uses https , that's the only difference.

Here's my code

        var printTask = new esriLoader.PrintTask(PrintTaskServiceUrl);
        esriLoader.Config.defaults.io.proxyUrl = proxyUrl;
        esriLoader.Config.defaults.io.alwaysUseProxy = true;
        var template = new esriLoader.PrintTemplate();
        template.exportOptions = {
            width: 1015,
            height: 633,
            dpi: 96 // if 200 ,map image will get good quality
        };
        template.format = "JPG";
        template.layout = "MAP_ONLY",
        template.preserveScale = false;
        template.showLabels = true;
        template.showAttribution = false;

        template.layoutOptions = {
            "legendLayers": [], // empty array means no legend
            "scalebarUnit": "Miles",
            "copyrightText": "<div>xxx</div>",
        }
        var params = new esriLoader.PrintParameters();

        params.map = map;
        params.template = template;

        printTask.execute(params, success, error);

Solution

  • I found the issue , Esri will not support GIF image when exporting map.When I debug , the layer details was sending with a url of image(gif), and issue solved when I replaced the gif with a png..

    {
            "id": "userLocation",
            "opacity": 1,
            "minScale": 0,
            "maxScale": 0,
            "featureCollection": {
                "layers": [{
                    "layerDefinition": {
                        "name": "pointLayer",
                        "geometryType": "esriGeometryPoint"
                    },
                    "featureSet": {
                        "geometryType": "esriGeometryPoint",
                        "features": [{
                            "geometry": {
                                "x": 76.299399,
                                "y": 9.963090099999999,
                                "spatialReference": {
                                    "wkid": 2226
                                }
                            },
                            "symbol": {
                                "angle": 0,
                                "xoffset": 0,
                                "yoffset": 0,
                                "type": "esriPMS",
                                "url": *"https://example.mine.com/Images/blue_marker.gif"*,
                                "width": 26.25,
                                "height": 26.25
                            }
                        }]
                    }
                }]
            }
        }
    

    Issue resolved when I changed to gif to png https://example.mine.com/Images/blue_marker.png