简体   繁体   中英

HTTP client PUT request error

I am making a PUT request using apache HTTP client in java but i am getting some error. here is my function for that :

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();
        }
    }

and the response i am getting is :

{"code":6,"message":"Internal Error"}

Where i am doing wrong?

This seems to be the response from the server. (I guess the actual output is postresp ==> {"code":6,"message":"Internal Error"} )

It is not an error in your code, but an internal error at the server side. You should check the server code/logs/contact the admin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM