x-www-form-urlencoded
의 본문을 로컬 웹 API에 보내려고합니다. GET
을 문제없이 만들 수 있습니다. 여기에 내가 할 것입니다 :content-length in HttpURLConnection
String urlParameters = "user=User&label=GPU+Temp&file=src%2FDataSource0.txt&backgroundColor=rgb(255%2C255%2C255%2C0)&borderColor=rgb(255%2C255%2C255%2C0)&pointBorderColor=rgb(255%2C255%2C255%2C0)&pointHoverBackgroundColor=rgb(255%2C255%2C255%2C0)&pointHoverBorderColor=rgb(255%2C255%2C255%2C0)&min=0&max=100&stepSize=50";
byte[] postData = urlParameters.getBytes(Charset.forName("UTF-8"));
int postDataLength = postData.length;
String request = "http://192.168.1.30:6262/api/values";
URL url = new URL(request);
con = (HttpURLConnection) url.openConnection();
con.setDoOutput(true);
con.setInstanceFollowRedirects(false);
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("charset", "utf-8");
con.setRequestProperty("Content-Length", Integer.toString(postDataLength));
con.connect();
java.net.ProtocolException : 내용 길이는 598 바이트를 약속하지만, 0
을 받았다 그래서 내가 어떤 데이터를 전송하고 있지 않다 것을 의미 내 POST
, 어떻게 오셨습니까?
쓰기 (postData를) 내가 생각했던 그건 – Mick