Story
Something we using postman as testing webservice tool.This article provide another way to test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| public static void main(String args []) throws Exception { URL url = new URL("http://127.0.0.1:8080/SYS/rest/twseInfo");
HttpURLConnection http = (HttpURLConnection)url.openConnection(); http.setRequestMethod("POST"); http.setDoOutput(true); http.setRequestProperty("Accept", "application/json"); http.setRequestProperty("Content-Type", "application/json"); String data = "{\"Info\":[{\"dataDate\":\"2021/12/08\",\"secCode\":\"1101\",\"secName\":\"AAAA\",\"paidInCapital\":63235800100,\"outstandingShares\":6123580010,\"pefundCommon\":0,\"preferredStock\":200000000,\"mospType\":\"TWSE\",\"createUser\":\"RPA Robot\",\"createDate\":\"2021-12-02 10:30:35\",\"procUser\":\"RPA Robot\",\"procDate\":\"2021-12-02 10:30:35\"},{\"dataDate\":\"2021/12/08\",\"secCode\":\"1102\",\"secName\":\"BBBBB\",\"paidInCapital\":63235800100,\"outstandingShares\":6123580010,\"pefundCommon\":0,\"preferredStock\":200000000,\"mospType\":\"TWSE\",\"createUser\":\"RPA Robot\",\"createDate\":\"2021-12-02 10:30:35\",\"procUser\":\"RPA Robot\",\"procDate\":\"2021-12-02 10:30:35\"}]}";
byte[] out = data.getBytes(StandardCharsets.UTF_8);
OutputStream stream = http.getOutputStream(); stream.write(out);
System.out.println(http.getResponseCode() + " " + http.getResponseMessage()); http.disconnect(); }
|