RestClient ResponseSpec.body() throws an exception instead of returning null
if no response body is available
#31719
Milestone
null
if no response body is available
#31719
From
RestClient.ResponseSpec
:Calling an API with the following:
If I stub out an endpoint with WireMock as an OK application/json response with no body:
I get an exception:
Or stubbing it out as just OK:
I get different exception:
Expected: null is returned as documented when no response body is returned, at least in the
okJson(null)
case (I suspect WireMock is defaulting to an octet body in the latter case...)Alternatively:
ResponseSpec.body()
is not nullable and is documented as throwing an exception in the case no body is availableUsing
okJson("null")
seems to work and null is returned, but that is an available response body. This is in contrast to WebClient'sblockOptional()
which did return an emptyOptional
forokJson(null)
andblock()
which returns null.The text was updated successfully, but these errors were encountered: