How to get response body to retrofit exception?

前端 未结 4 1137
梦如初夏
梦如初夏 2021-02-01 02:12

I am trying to connect to rest service via retrofit in android application. I am getting responses. But when there is some error response from the service, conversion exception

4条回答
  •  [愿得一人]
    2021-02-01 03:06

    you need use getErrorStream() for this.

    If the HTTP response indicates that an error occurred, getInputStream() will throw an IOException. Use getErrorStream() to read the error response. The headers can be read in the normal way using getHeaderFields().

    Ref: github issue

提交回复
热议问题