title: Getting error 400 bad request in retrofit but works on postman
body: <p>I have to send images and data to Retrofit2 multipart. The image may contain multiple images or no images at all. If you set the image to <code>null</code> in the postman and put the jsonObject as it is, it will be sent. But in the android studio, it is not being sent. I don't know why it doesn't work.</p>
  <pre><code>interface myRetrofitInterface {
  @Multipart
  @POST(&quot;--my--&quot;)
  fun Question(
      @Header(&quot;X-ACCESS-TOKEN&quot;) X_ACCESS_TOKEN: String,
      @Part (&quot;Que&quot;) Que: RequestBody,
      @Part images: List&lt;MultipartBody.Part?&gt;?,
      ): Call&lt;--myResponse--&gt;
  </code></pre>
  <p>}</p>
  <p>Service.kt</p>
  <pre><code>fun Question(
      jwt: String, userIdx: Long, CategoryIdx: Long, title: String, Url: String?, images: ArrayList&lt;MultipartBody.Part?&gt;?
  ) {
  
      val myService = getRetrofit().create(--myRetrofitInterface--::class.java)
  
      val jsonObject =
          JSONObject(&quot;{\&quot;userIdx\&quot;:${userIdx},\&quot;CategoryIdx\&quot;:${CategoryIdx},\&quot;title\&quot;:\&quot;${title}\&quot;,\&quot;Url\&quot;:\&quot;${Url}\&quot;}&quot;).toString()
      val Que = jsonObject.toRequestBody(&quot;application/json&quot;.toMediaTypeOrNull())
      Log.d(&quot;json/jsonObject&quot;, jsonObject)
  
      --myView--.onLoading()
  
      --myService--.Question(
          jwt, Que, images
      ).enqueue(object : Callback&lt;-- myResponse --&gt; {
          override fun onResponse(call: Call&lt;--myResponse--&gt;, response: Response&lt;--myResponse--&gt;) {
          Log.d(&quot;API-RESPONSE&quot;, response.toString())
          Log.d(&quot;API-error&quot;, response.errorBody()!!.string())
          //                Log.d(&quot;json/jsonObject&quot;, jsonObject)
          if (response.isSuccessful &amp;&amp; response.code() == 200) {
              val resp = response.body()!!
              Log.d(&quot;API-SUCCESS&quot;, resp.toString())
  
              when (resp.code) {
                  1000 -&gt; --myView - . onSuccess (resp.result)
  
                  else -&gt; --myView--.onFailure(resp.code, resp.message)
              }
          }
      }
  
          override fun onFailure(call: Call&lt;--myResponse--&gt;, t: Throwable) {
          -myView--.onFailure(400, &quot;error.&quot;)
          Log.d(&quot;API-ERROR&quot;, t.message.toString())
      }
      })
  }
  </code></pre>
  <p>Log</p>
  <pre><code>D/json/jsonObject: {&quot;userIdx&quot;:13,&quot;CategoryIdx&quot;:5,&quot;title&quot;:&quot;asd&quot;,&quot;Url&quot;:&quot;jkjk&quot;}
  D/API-RESPONSE: Response{protocol=http/1.1, code=400, message=, url=--my Url--}
  D/API-error: {&quot;timestamp&quot;:&quot;2022-04-10T18:36:45.061+00:00&quot;,&quot;status&quot;:400,&quot;error&quot;:&quot;Bad Request&quot;,&quot;path&quot;:&quot;--my path--&quot;}
  </code></pre>