//JAVA REST POST MapRoute
      //POST https://pcmiler.alk.com/apis/rest/v1.0/Service.svc/mapRoutes?dataset={dataset}
      
      String address;
      String baseURL = "http://pcmiler.alk.com/APIs/REST/V1.0/Service.svc/";

            address = baseURL + "mapRoutes?dataset=Current";
           
            url = new URL(address);

            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setDoOutput(true);//
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Content-Type", "application/json");

            conn.setRequestProperty("Authorization", apiKeyVal);
            

            queryStr.setText("{ \"Map\":{ \"Viewport\":{ \"Center\":null, \"ScreenCenter\":null, \"ZoomRadius\":2, \"CornerA\":null, \"CornerB\":null, \"Region\":0 }, \"Projection\":0, \"Style\":0, \"ImageOption\":0, \"Width\":986, \"Height\":688, \"Drawers\":[ 4, 5, 6, 8, 2, 7, 9, 10, 11, 12, 13, 14, 22, 17, 15 ], \"LegendDrawer\":[ { \"Type\":0, \"DrawOnMap\":true } ], \"GeometryDrawer\":null, \"PinDrawer\":null, \"PinCategories\":null, \"TrafficDrawer\":null, \"MapLayering\":0, \"Language\":null, \"ImageSource\":null }, \"Routes\":[ { \"RouteId\":null, \"Stops\":[ { \"Address\":{ \"StreetAddress\":null, \"City\":\"New York\", \"State\":\"NY\", \"Zip\":\"12345\", \"County\":null, \"Country\":null, \"SPLC\":null, \"CountryPostalFilter\":0, \"AbbreviationFormat\":0 }, \"Coords\":null, \"Region\":4, \"Label\":\"1\", \"PlaceName\":null, \"Costs\":null, \"IsViaPoint\":false }, { \"Address\":{ \"StreetAddress\":null, \"City\":\"Lincoln\", \"State\":\"NE\", \"Zip\":\"\", \"County\":null, \"Country\":null, \"SPLC\":null, \"CountryPostalFilter\":0, \"AbbreviationFormat\":0 }, \"Coords\":null, \"Region\":4, \"Label\":\"stop2\", \"PlaceName\":null, \"Costs\":null, \"IsViaPoint\":false }, { \"Address\":{ \"StreetAddress\":null, \"City\":\"Seattle\", \"State\":\"WA\", \"Zip\":\"\", \"County\":null, \"Country\":null, \"SPLC\":null, \"CountryPostalFilter\":0, \"AbbreviationFormat\":0 }, \"Coords\":null, \"Region\":4, \"Label\":\"3\", \"PlaceName\":null, \"Costs\":null, \"IsViaPoint\":false } ], \"Options\":{ \"AFSetIDs\":null, \"BordersOpen\":null, \"ClassOverrides\":0, \"DistanceUnits\":0, \"ElevLimit\":null, \"FerryDiscourage\":false, \"FuelRoute\":false, \"HazMatType\":0, \"HighwayOnly\":true, \"HubRouting\":false, \"OverrideRestrict\":false, \"RouteOptimization\":0, \"RoutingType\":0, \"TollDiscourage\":false, \"TruckCfg\":null, \"UseAvoidsAndFavors\":false, \"VehicleType\":0 }, \"FuelOptions\":null, \"DrawLeastCost\":false, \"RouteLegOptions\":null, \"StopLabelDrawer\":2 } ] } ");
            String input = queryStr.getText();

            OutputStream os = conn.getOutputStream();
            os.write(input.getBytes());
            os.flush();
            if (conn.getResponseCode() != 200) {
                if (conn.getResponseCode() != HttpURLConnection.HTTP_CREATED) {
                    throw new RuntimeException("Failed : HTTP error code : "
                            + conn.getResponseCode());
                }
            }

            String type = conn.getContentType();

            if (type == null) {
                return;
            }

            if (type.equalsIgnoreCase("image/png")) {

                InputStream source = conn.getInputStream();
                BufferedImage bi = ImageIO.read(source);
        //Write to file or output to JFrame JTextPanel below
               // File f = new File("c:\\users\\ksouders\\solo.png");
               // ImageIO.write(bi, "png", f);
                ByteArrayOutputStream bas = new ByteArrayOutputStream();
                ImageIO.write(bi, "png", bas);
                byte[] map = bas.toByteArray();
                jScrollPane2.add(jtp);

                jTextPane1.insertIcon(new ImageIcon(bi));
                jtp.insertIcon(new ImageIcon(bi));
                source.close();
                bas.close();
            }

        } catch (IOException ex) {
            Logger.getLogger(JavaRestFrame.class.getName()).log(Level.SEVERE, null, ex);
            jTextPane1.setText("IOException: " + ex);
        }

This sample may use features that are only available in our Premium WebServices. Please refer to our Features page to confirm what feature level you currently subscribe to.