import java.io.*; import java.net.*; public class TestApi { public static void main(String[] args) { try { URL url = new URL("http://localhost:8448/system/businessScene"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestProperty("Authorization", "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImNyZWF0ZWQiOjE3MTg1NDkzODAxNzYsImV4cCI6MTcxODU1Mjk4MH0.SP8Jv6X8n4YJ6K5YJ6K5YJ6K5YJ6K5YJ6K5YJ6K5YJ6K5YJ6K5YJ6K5YJ6K5YJ6K5YJ6K5YJ6K5Y"); conn.setDoOutput(true); String jsonInputString = "{" + "\"sceneName\": \"TestScene\"," + "\"thirdPersonCameraPos\": \"[-2794881.16,5012908.69,2782554.46]\"," + "\"thirdPersonCameraTarget\": \"[-2794881.16,5012908.69,0]\"," + "\"thirdPersonCameraHeading\": 0.8474376369888388," + "\"thirdPersonCameraPitch\": -0.47481682300505734," + "\"thirdPersonCameraRoll\": 6.2831853071795845," + "\"thirdPersonCameraDirection\": \"[-0.25689388313349093,-0.9082555319630337,0.3302687110023337]\"," + "\"thirdPersonCameraUp\": \"[-0.6247398838094573,0.4168025198968015,0.660284587875124]\"," + "\"status\": \"0\"," + "\"remark\": \"Test\"" + "}"; try (OutputStream os = conn.getOutputStream()) { byte[] input = jsonInputString.getBytes("utf-8"); os.write(input, 0, input.length); } int code = conn.getResponseCode(); System.out.println("Response code: " + code); BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8")); StringBuilder response = new StringBuilder(); String responseLine = null; while ((responseLine = br.readLine()) != null) { response.append(responseLine.trim()); } System.out.println("Response body: " + response.toString()); conn.disconnect(); } catch (Exception e) { e.printStackTrace(); } } }