UnsupportedOperationException:无效的内容类型应用程序/ json
问题描述:
我通过放心自动化其余api。UnsupportedOperationException:无效的内容类型应用程序/ json
当我通过REST客户端测试相同的API我没有得到任何问题,但是当我通过Rest Assured
自动化我得到无效的内容类型错误。
我的REST API是如下:
Response res = given()
.relaxedHTTPSValidation()
.body(model)
.with()
.contentType("application/json")
.then()
.post(ConfigReader.get("asset.temperature.push.url"));
return res.body().asString();
错误是:
{"message":"Execution exception[[UnsupportedOperationException: Invalid content type. Content-Type should be application/json or text/json, receivedapplication/json; charset=UTF-8]]"}
如何来解决这个问题
答
这是问题,因为内部的应用程序,它直接验证导致问题的内容类型为"application/json; charset=utf-8"
。
默认情况下,放心将发送默认字符集UTF-8
,但作为应用程序验证utf-8
它导致了问题。
无论如何反对申请引发的问题来解决这个问题。