public RequestBody serialize ( Object obj , String contentType ) throws ApiException { if ( obj instanceof byte [ ] ) { // Binary (byte array) body parameter support. return RequestBody . create ( MediaType . parse ( contentType ) , ( byte [ ] ) obj ) ; } else if ( obj instanceof File ) { // File body parameter support. return RequestBody . create ( MediaType . parse ( contentType ) , ( File ) obj ) ; } else if ( isJsonMime ( contentType ) ) { String content ; if ( obj != null ) { content = json . serialize ( obj ) ; } else { content = null ; } return RequestBody . create ( MediaType . parse ( contentType ) , content ) ; } else { throw new ApiException ( "Content type \"" + contentType + "\" is not supported" ) ; } }
Serialize the given Java object into request body according to the object s class and the request Content - Type .