我需要将此curl转换为java代码
curl -G \
-u "{user}":"{pass}" \
-d "version=2018-03-16" \
-d "the msg" \
-d "features=entities" \
-d "entities.model={modelID}" \
"https://gateway.watsonplatform.net/natural-language-understanding/api/v1/analyze"
我的java代码是那样的
URL url = new URL(uri.toString());
HttpURLConnection handle = (HttpURLConnection) url.openConnection();
String userpass = "{user}:{pass}";
new Base64();
String basicAuth = "Basic " + new String(Base64.encode(userpass.getBytes()));
handle.setRequestMethod("POST");
handle.setRequestProperty("Content-Type", "application/json");
handle.setRequestProperty("Authorization", basicAuth);
handle.setRequestProperty("version", "2018-03-16");
handle.setRequestProperty("text", params.getParameterString());
handle.setRequestProperty("features", "entities");
handle.setRequestProperty("entities.model", wksModel);
handle.setDoOutput(true);
这给了我400错误,所以你不知道我的错误在哪里,我希望你能帮助我