Skip to content

Request Body

Orhan Obut edited this page Aug 9, 2015 · 2 revisions

@Body can be used to add an object for request body. Object will be converted to json.

    @POST("/repos")
    void addName(
        @Body Repo repo,
        Callback<Repo> callback
    );

    service.addName(new Repo("3423",3),callback);

@BodyMap can be used to add a Map object instead of creating body class. It will be converted to json. You can use @BodyMap for the simple operations which you don't want to create a class.

    @POST("/repos")
    void addName(
        @BodyMap Map map,
        Callback<Repo> callback
    );

    Map map = new HashMap<>();
    map.put("ip","3423");
    map.put("page",3);

    service.addName(map, callback);
Clone this wiki locally