Post fields in this format with Retrofit

So I need to send an API request in this format

“access_key”: “6477848488cchfc47488”,
“person”: {
“first_name”: “John”,
“last_name”: “Henry”,
“email”: “”

I have created an object

public class Person {
    public String first_name = "";
    public String last_name = "";
    public String email = "";

In my interface I have

void sendDetails(@Field("person") Person person, @Field("access_key") String accessKey, Callback<User> cb);

Finally in my Activity I have the code below to call the send details method

Person person = new Person("John", ":"Henry, "");
  aApi.sendDetails(person, ACCESS_KEY, new Callback<User>() {
        public void success(User user, Response response) {


        public void failure(RetrofitError error) {


The server still doesn’t get my request in the right format. I’ve just switched from volley to retrofit. Would appreciate any help.

Source: json

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.