Sending HTTP DELETE request in Android

后端 未结 9 1618
悲哀的现实
悲哀的现实 2020-12-15 04:02

My client\'s API specifies that to remove an object, a DELETE request must be sent, containing Json header data describing the content. Effectively it\'s the same call as ad

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-15 04:40

    The problematic line is con.setDoOutput(true);. Removing that will fix the error.

    You can add request headers to a DELETE, using addRequestProperty or setRequestProperty, but you cannot add a request body.

提交回复
热议问题