title: Retrofit response with internal error with code 500
body: <p>trying to use post/put call method in my Kotlin frontend to get response from Django backend. Method Get works but if I use ResponseBody nothing happens and log gives error with code 500.
  Can someone help me?</p>
  <p>This is my Api interface, where PUT and POST method doesnt work</p>
  <pre><code>public interface Api {
  
      @GET(&quot;api/users&quot;)
      fun getUsers(): Call&lt;UserResults&gt;
  
      @PUT(&quot;/api/users/{Id}&quot;)
      suspend fun updateUser(@Body requestBody: RequestBody, @Path(&quot;Id&quot;) userId: String): Response&lt;ResponseBody&gt;
  
      @POST(&quot;/api/users&quot;)
      suspend fun createUser(@Body requestBody: RequestBody): Response&lt;ResponseBody&gt;
  }
  </code></pre>
  <p>This is function for example for PUT method</p>
  <pre><code>private fun updateSettings(preferredBranch: String) {
          // Create Retrofit
          val retrofit = Retrofit.Builder()
              .baseUrl(BASE_URL)
              .build()
  
          // Create Service
          val service = retrofit.create(Api::class.java)
  
          // Create JSON using JSONObject
          val jsonObject = JSONObject()
          jsonObject.put(&quot;preferred_branch&quot;, preferredBranch)
          //jsonObject.put(&quot;job&quot;, &quot;iOS Developer&quot;)
  
          // Convert JSONObject to String
          val jsonObjectString = jsonObject.toString()
  
          // Create RequestBody ( We're not using any converter, like GsonConverter, MoshiConverter e.t.c, that's why we use RequestBody )
          val requestBody = jsonObjectString.toRequestBody(&quot;application/json&quot;.toMediaTypeOrNull())
  
          CoroutineScope(Dispatchers.IO).launch {
  
              // Do the PUT request and get response
              val response = service.updateUser(requestBody, logId.toString())
  
              withContext(Dispatchers.Main) {
                  if (response.isSuccessful) {
  
                      // Convert raw JSON to pretty JSON using GSON library
                      val gson = GsonBuilder().setPrettyPrinting().create()
                      val prettyJson = gson.toJson(
                          JsonParser.parseString(
                              response.body()
                                  ?.string() // About this thread blocking annotation : https://github.com/square/retrofit/issues/3255
                          )
                      )
  
                      Log.d(&quot;Pretty Printed JSON :&quot;, &quot;test&quot;)
  
                  } else {
  
                      Log.e(&quot;RETROFIT_ERROR&quot;, response.code().toString())
  
                  }
              }
          }
      }
  </code></pre>