Problem
RequestAdapter.adapt passes a null body straight to OkHttp:
val okhttpBody = request.body?.let { toOkHttpBody(it) }
builder.method(request.method.method, okhttpBody) // RequestAdapter.kt:55-56
For POST/PUT/PATCH, OkHttp's Request.Builder.method throws IllegalArgumentException("method X must have a request body") when the body is null. A body-less POST is valid HTTP, and nothing stops a caller from building one: Request.RequestBuilder.build() only requires method and url (Request.kt:254-257) and Method carries no body-requirement metadata. Because the failure is an IllegalArgumentException (not an IOException), it also bypasses retry. The JDK transport does not have this problem, so behaviour differs across transports.
Proposed change
When body == null and the method permits/requires a body (POST/PUT/PATCH), pass an empty request body instead of null. Audit the JDK transport for parity (BodyPublishers.noBody()).
Acceptance
Priority: high · Effort: small
Problem
RequestAdapter.adaptpasses a null body straight to OkHttp:For POST/PUT/PATCH, OkHttp's
Request.Builder.methodthrowsIllegalArgumentException("method X must have a request body")when the body is null. A body-less POST is valid HTTP, and nothing stops a caller from building one:Request.RequestBuilder.build()only requiresmethodandurl(Request.kt:254-257) andMethodcarries no body-requirement metadata. Because the failure is anIllegalArgumentException(not anIOException), it also bypasses retry. The JDK transport does not have this problem, so behaviour differs across transports.Proposed change
When
body == nulland the method permits/requires a body (POST/PUT/PATCH), pass an empty request body instead of null. Audit the JDK transport for parity (BodyPublishers.noBody()).Acceptance
Priority: high · Effort: small