cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benson Margulies <bimargul...@gmail.com>
Subject Re: How to submit JSON data as request body in Apache CXF jax-rs (REST)
Date Sun, 01 May 2011 12:41:55 GMT
Don't you just need another @Consumes on the new function? Or just on
the whole class?

On Sun, May 1, 2011 at 1:01 AM, arnavawasthi <arnavawasthi@gmail.com> wrote:
> Thanks, that worked.
>
> But now, if I want to post List of Customers in JSON in the following way:
>
>    @POST
>    @Path("/addCustomers/")
>    @Consumes(MediaType.APPLICATION_JSON)
>    //{"Customer":[{"id":2999,"name":"Som Awasthi"},{"id":3000,"name":"Arnav
> Awasthi"}]}
>    public List<Customer> addCustomers(List<Customer> list){
>        logger.debug(list);
>        return list;
>    }
>
> Request Header:
> Content-Type: application/json
>
> Request Body:
> {"Customer":[{"id":2999,"name":"Som Awasthi"},{"id":3000,"name":"Arnav
> Awasthi"}]}
>
> Again the "415: Unsupported Media Type" error.
>
> Input to this request is same, what I have got in the listCustomers call,
> which is as follows:
>
>    @GET
>    @Path("/listCustomers")
>    public List<Customer> listCustomers(){
>        List<Customer> list = new ArrayList<Customer>();
>        list.add(new Customer("Som Awasthi", 2999L));
>        list.add(new Customer("Arnav Awasthi", 3000L));
>
>        return list;
>    }
>
> Regards,
> Arnav--
> View this message in context: http://cxf.547215.n5.nabble.com/How-to-submit-JSON-data-as-request-body-in-Apache-CXF-jax-rs-REST-tp4361669p4362318.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>

Mime
View raw message