Is it possible to send a String[] through Multipart using Retrofit?
<p>I'm developing an application where at a point the user has to choose any number of countries from a list and I must send the selected names through a multipart.</p>

<p>I am not uploading any file along with the String[], but there is no route to upload information without it being a multipart and I don't have any saying in how the web server operates.</p>

<p>I've attempted to simply send it as an Array, ArrayList and JsonArray as such:</p>

<pre><code>@Headers({
    "Connection: Keep-Alive",
})
@Multipart
@PUT("/user/{id}")
String updateUser(@Path("id") int userId, @Part("user[countries]") String[] countries);
</code></pre>

<p>I've also attempted <a href="https://github.com/square/retrofit/issues/811" rel="noreferrer">this solution</a>, but I either misunderstood it or it does not work. Here is the code I attempted to use:</p>

<pre><code>ArrayList&lt;String&gt; countries = CountryManager.getInstance().getSelectedCountryIds();
RequestBody requestBody;
LinkedHashMap&lt;String, RequestBody&gt; hashMap = new LinkedHashMap&lt;&gt;();

for(int i = 0; i &lt; countries.size(); i++) {
    requestBody = RequestBody.create(MediaType.parse("text/plain"), countries.get(i));
    hashMap.put("countries["+i+"]", requestBody);
}
</code></pre>

<p>And changing the retrofit method accordingly:</p>

<pre><code>@Headers({
    "Connection: Keep-Alive",
})
@Multipart
@PUT("/user/{id}")
String updateUser(@Path("id") int userId, @PartMap() Map countries);
</code></pre>

<p>However in all attempts I've gotten the error retrofit.RetrofitError: Part body must not be null.</p>

<p>I've also mentioned that the ChangeLog for retrofit mentions "New: Support iterable and array <code>@Part</code> parameters using OkHttp's <code>MultipartBody.Part</code>", but after some digging, I've found the given example quite confusing to the point that I'm unsure on how to implement it in my code and was unable to find a tutorial that even mentioned sending arrays in a multipart.</p>

<p>Is such a thing simply impossible?</p>