将Curl-G转换为java代码

将Curl-G转换为java代码,java,curl,Java,Curl,我需要将这个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代码是这样的 UR

我需要将这个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,所以您不知道我的错误在哪里,我希望您能帮助我

您的curl send请求,其中all-d参数附加到url,如GET request(),因此,我将在url的“?”之后添加handle.setRequestProperty。400响应的主体是否给出了问题的线索?您使用的是java的post,而使用的是curl,如果您请求的url不支持post,那么您的代码将无法工作,请发邮件,因为我们无法检查所发邮件的内容,因为缺少一些信息