I get this error: `Request of type HttpMethod(valu...
# ktor
s
I get this error:
Request of type HttpMethod(value=GET) couldn't send a body with the Android engine.
I see that specifically on the Android engine I cannot send a GET request with an empty body but am unsure of the reasoning for this.
e
Hi @Shan, thanks for the notice. Could you provide the use case of the empty body? Probably we can allow this special case, but there is no difference between
absent
and
empty
here.
btw
Android
engine uses
UrlConnection
under the hood.
s
The issue was from setting the ContentType in my default request (
contentType(ContentType.Application.Json)
). When making a GET request with the ContentType as Json it adds an empty
{}
to the body (even when not setting the body at all, or manually setting it to NoContent) which makes the body appear to have something inside of it I suppose. I did a manual
if (method != HttpMethod.Get) contentType(ContentType.Application.Json)
in my default HttpRequestBuilder block and it is working alright now, though I'm not sure that's intended behavior.