Retrofit 2 send object with POST
<p>i m new about Retrofit Library and i want know what s the better why to send an object with post method of retrofit.</p>

<p>Here is it some code.</p>

<p>My Class:</p>

<pre><code>public class ExampleClass implements Serializable {

    @SerializedName("id")
    int id;


    @SerializedName("name")
    String name;

    public ExampleClass(int id, String name) {
        this.id = id;
        this.name= name;
    }

}
</code></pre>

<p>My interface:</p>

<pre><code>public interface ApiInterface {
    @Headers("Content-Type: application/json")
    @POST("getclass/")
    Call&lt;ExampleClass&gt; getExampleClass(@Body ExampleClass exampleClass);
}
</code></pre>

<p>My call with retrofit:</p>

<pre><code>......
        ApiInterface apiService = ApiClient.getClient().create(ApiInterface.class);
        Call&lt;ExampleClass&gt; call = apiService.getExampleClass(exampleClass);
        call.enqueue(new Callback&lt;ExampleClass&gt;() {
            @Override
            public void onResponse(Call&lt;ExampleClass&gt; call, Response&lt;ExampleClass&gt; response) {

                int statusCode = response.code();

                Log.i(TAG, "Status Code: " + statusCode);

            }

            @Override
            public void onFailure(Call&lt;ExampleClass&gt; call, Throwable t) {
                Log.i(TAG, "Error: " + t.toString());
            }

        });
</code></pre>

<p>But every time it return me status code 500.</p>

<p>Can someone give me an idea for send an object with retrofit?</p>