文本/html的Rest API解析失败,因为它解析为应用程序/json

文本/html的Rest API解析失败,因为它解析为应用程序/json,json,rest,api,html-parsing,httpresponse,Json,Rest,Api,Html Parsing,Httpresponse,对于RESTAPI响应代码404,我得到的响应内容类型为text/HTML。但它试图将此响应解析为application/json,因此我得到如下解析错误 org.apache.http.headers - << Content-Length: 153 org.apache.http.headers - << Connection: keep-alive c.s.c.u.r.RestClientUtil$1 - Parsing response as: applicati

对于RESTAPI响应代码404,我得到的响应内容类型为text/HTML。但它试图将此响应解析为application/json,因此我得到如下解析错误

org.apache.http.headers - << Content-Length: 153
org.apache.http.headers - << Connection: keep-alive
c.s.c.u.r.RestClientUtil$1 - Parsing response as: application/json
groovyx.net.http.ParserRegistry - Could not find charset in response; using UTF-8
org.apache.http.wire -  << "<html>[\r][\n]"
org.apache.http.wire -  << "<head><title>404 Not Found</title></head>[\r][\n]"
org.apache.http.wire -  << "<body>[\r][\n]"
org.apache.http.wire -  << "<center><h1>404 Not Found</h1></center>[\r][\n]"
org.apache.http.wire -  << "<hr><center>nginx/1.17.8</center>[\r][\n]"
org.apache.http.wire -  << "</body>[\r][\n]"
org.apache.http.wire -  << "</html>[\r][\n]"
c.s.c.u.r.RestClientUtil$1 - Error parsing 'text/html' response
groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object

The current character read is '<' with an int value of 60
Unable to determine the current character, it is not a string, number, array, or object```

my code has below parser hich is calling Httpbuilder.java function- ParserRegistry getParser() {return this.parsers;}.
```newRestClient.parser['application/error+json'] = newRestClient.parser['application/json']
        newRestClient.parser['application/error+json;version=2;charset=UTF-8'] = newRestClient.parser['application/json']```

can I add some here which can also handle text/HTML response content type?

org.apache.http.headers-有人知道我如何继续吗?有人知道我如何继续吗?