//JAVA REST POST RouteReports https://pcmiler.alk.com/apis/rest/v1.0/Service.svc/route/routeReports?dataVersion={dataVersion}
    
    

   String baseURL = "http://pcmiler.alk.com/APIs/REST/V1.0/Service.svc/";
       
           String address = baseURL + "route/routeReports?dataset=Current";
            }
     

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

            
            queryStr.setText(" { \"ReportRoutes\": [ { \"ReportingOptions\": { \"UseTollData\": true, \"FuelUnits\": 0, \"RouteCosts\": { \"FuelEconomyLoaded\": 8.5, \"FuelEconomyEmpty\": 11.9, \"PricePerFuelUnit\": 13, \"TruckStyle\": 0, \"GreenHouseGas\": 5.2, \"OtherCostPerDistUnitLoaded\": 12.2, \"OtherCostPerDistanceUnitEmpty\": 8.9, \"CostTimeLoaded\": 15.5, \"CostTimeEmpty\": 12.6 }, \"TimeCosts\": { \"DepartTime\": null, \"BreakInterval\": 0, \"BreakLength\": 0, \"BorderWait\": 0, \"RemainingHoursOfService\": 0 }, \"TollCurrency\": 0, \"ExchangeRate\": 1.01, \"TollDiscount\": \"ezpass\", \"IncludeFerryDistance\": true, \"UseCustomRoadSpeeds\": false, \"Language\": 0, \"EstimatedTimeOptions\": null, \"UseTraffic\": false, \"TruckStyle\": 0 }, \"ReportTypes\": [ { \"__type\": \"DirectionsReportType:http:\\/\\/pcmiler.alk.com\\/APIs\\/v1.0\", \"CondenseDirections\": false } ], \"RouteId\": null, \"Stops\": [ { \"Costs\": null, \"IsViaPoint\": false, \"Address\":{ \"StreetAddress\": \"457 N Harrison St\", \"City\": \"Princeton\", \"State\": \"NJ\", \"Zip\":08540, \"County\":null, \"Country\":null, \"SPLC\":null, \"CountryPostalFilter\":0, \"AbbreviationFormat\":0 }, \"Coords\": null, \"Region\": 4, \"Label\": null, \"PlaceName\": null }, { \"Costs\": null, \"IsViaPoint\": false, \"Address\": null, \"Coords\": { \"Lat\": \"42.123120\", \"Lon\": \"-76.123120\" }, \"Region\": 4, \"Label\": null, \"PlaceName\": null }, { \"Costs\": null, \"IsViaPoint\": false, \"Address\": null, \"Coords\": { \"Lat\": \"42.124560\", \"Lon\": \"-76.124560\" }, \"Region\": 4, \"Label\": null, \"PlaceName\": null } ], \"Options\": { \"VehicleType\": 0, \"RoutingType\": 1, \"HighwayOnly\": true, \"FuelRoute\": false, \"UseAvoidsAndFavors\": false, \"ClassOverrides\": 1, \"DistanceUnits\": 0, \"TollDiscourage\": true, \"BordersOpen\": true, \"OverrideRestrict\": false, \"HazMatType\": 3, \"RouteOptimization\": 2, \"TruckCfg\": { \"Units\": 0, \"Height\": \"13'6\\\"\", \"Length\": \"53'\", \"Width\": \"96\\\"\", \"Weight\": \"14000\", \"Axles\": 8, \"LCV\": false }, \"HubRouting\": false, \"AFSetIDs\": null, \"ElevLimit\": null, \"FerryDiscourage\": false, \"HoSOptions\": { \"Enabled\": false, \"ConsecutiveDriveTime\": null, \"TotalDriveTime\": null, \"TotalOnDutyTime\": null } }, \"FuelOptions\": null } ] } ");
         

            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;
            }
            BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));

            String output;
            System.out.println("Output from Server .... ");
            while ((output = br.readLine()) != null) {
                System.out.println(output);

                //Pretty Print JSON object
                ObjectMapper mapper = new ObjectMapper();
                try {
                    Object jsonObj = mapper.readValue(output.toString(), Object.class);
                    String indented = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonObj);

                    jTextPane1.setText(indented);

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

        } 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.