1
我在java中使用apache HTTP客户端发出PUT请求,但是我收到了一些错误。这里是我的那个功能:HTTP客户端PUT请求错误
public static void putRequest(String url, JSONObject setObject)
{
try
{
PutMethod put = new PutMethod(url);
HttpMethodParams httpParams = new HttpMethodParams();
if(setObject != null)
httpParams.setParameter("JSONString", setObject.toJSONString());
put.setParams(httpParams);
try
{
int result = httpclient.executeMethod(put);
System.out.println("HTTP response code : " + result);
String getResp = put.getResponseBodyAsString();
System.out.println("postresp ==> " + getResp);
put.releaseConnection();
}
catch(Exception e)
{
e.printStackTrace();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
和我得到的回应是:
{"code":6,"message":"Internal Error"}
我哪里做错了吗?
您的错误来自端点url。可能,您提供的数据是错误的,并且在后端出现错误 –