Description
What kind of issue is this?
-
Question. This issue tracker is not the place for questions. If you want to ask how to do
something, or to understand why something isn't working the way you expect it to, use Stack
Overflow. https://stackoverflow.com/questions/tagged/retrofit -
Bug report. If you’ve found a bug, spend the time to write a failing test. Bugs with tests
get fixed. Here’s an example: https://gist.github.com/swankjesse/6608b4713ad80988cdc9 -
Feature Request. Start by telling us what problem you’re trying to solve. Often a solution
already exists! Don’t send pull requests to implement new features without first getting our
support. Sometimes we leave features out on purpose to keep the project small.
I tried to use retrofit to send requests to a server that has some blocking rules. When I was trying to send a request to my backend with Multipart, it didn't reach my backend. I spent some time investigating why it happened and I found that my requisition lacked charset sent with multipart/form-data.
The code that I had to written on OkHttp:
val mediaType = "multipart/form-data; charset=utf-8".toMediaType()
val headers = Headers.headersOf("Content-Disposition", "form-data; name=\"myjson\"")
val multipartPartBody = """{"body":"hello"}""".toRequestBody()
val multipartBody = MultipartBody.Builder()
.setType(mediaType)
.addPart(headers, multipartPartBody)
.build()
val request = Request.Builder()
.url(myUrl)
.put(multipartBody)
.build()
val response = client.newCall(request).execute()
I couldn't send this way to the backend with Retrofit
I just wanted a way to send a request with this charset with Retrofit