How to send PUT, DELETE HTTP request in HttpURLConnection in JAVA

前端 未结 3 1245
[愿得一人]
[愿得一人] 2020-12-30 09:25

I have Restful WebServices, and i send POST and GET HTTP request, how to send PUT and DELTE request HTTP in httpURLConection with JAVA.

3条回答
  •  星月不相逢
    2020-12-30 10:12

    If I use the DELETE request from @BartekM, it get this exception:

     java.net.ProtocolException: DELETE does not support writing
    

    To fix it, I just remove this instruction:

     // httpURLConnection.setDoOutput(true);
    

    source: Sending HTTP DELETE request in Android

提交回复
热议问题