【发布时间】:2023-03-21 14:02:01
【问题描述】:
我正在尝试使用 Jsoup 将数据作为 json 发布到 api,但是 api 给我一个错误提示
There was an unexpected error (type=Unsupported Media Type, status=415).
Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
Jsoup 请求:
Jsoup.connect(apiConfiguration.getHttpBaseAddress()+url)
.validateTLSCertificates(false)
.maxBodySize(0)
.timeout(180000)
.ignoreHttpErrors(true)
.header("Authorization", apiConfiguration.getLoginString())
.header("Content-Type", "application/json")
.header("cache-control", "no-cache")
.method(Connection.Method.POST)
.requestBody(reqBodyStr)//POJO, parsed with Gson --> String
.execute();
可能Jsoup没有改变内容类型?我也试过先设置requestBody,再设置内容类型,但都是一样的。
【问题讨论】: