Return-Path: X-Original-To: apmail-cxf-users-archive@www.apache.org Delivered-To: apmail-cxf-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E415A2757 for ; Sun, 1 May 2011 12:42:24 +0000 (UTC) Received: (qmail 90912 invoked by uid 500); 1 May 2011 12:42:24 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 90868 invoked by uid 500); 1 May 2011 12:42:24 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 90860 invoked by uid 99); 1 May 2011 12:42:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 May 2011 12:42:24 +0000 X-ASF-Spam-Status: No, hits=0.6 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of bimargulies@gmail.com designates 209.85.214.41 as permitted sender) Received: from [209.85.214.41] (HELO mail-bw0-f41.google.com) (209.85.214.41) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 May 2011 12:42:19 +0000 Received: by bwz17 with SMTP id 17so5083460bwz.0 for ; Sun, 01 May 2011 05:41:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=nfGX2F/5UJwP1niXIMq9Ct2IS+DPy0yDSpGxrq0OO5M=; b=Siijhb3ZfiZCjh6w4ClxryresfDFv8/LZ7OjPbf+ObBGIOG6Gw3HdypMVJQe7k6inz aTItJk4phwvvgFwesXzyfdKmY2pLDqCo5RqVAQVWZq/t1bALOCdXtoYyIXwM6+uUVP9v 3osD/QznZNV2VtUfqAwY2JCENYjDdkBoafQcY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=xQbFfzFTehqVUbHB8n8wGa4ENQDqmmyFGIUBs7WjKchoFF5vpZtHkYtVvDK37nsCjz R1WE3/IYyaR5GJRAHWor8lECMnIuiAGVj8xQyX39xjnz+IJMnh4H0KLtSCcaCuStXbze BmrvNbysePbRHR5sAXgltDMl61oh4dLYCT/Qs= MIME-Version: 1.0 Received: by 10.204.26.132 with SMTP id e4mr2117506bkc.142.1304253715975; Sun, 01 May 2011 05:41:55 -0700 (PDT) Received: by 10.205.37.129 with HTTP; Sun, 1 May 2011 05:41:55 -0700 (PDT) In-Reply-To: <1304226093490-4362318.post@n5.nabble.com> References: <1304194550268-4361669.post@n5.nabble.com> <1304226093490-4362318.post@n5.nabble.com> Date: Sun, 1 May 2011 08:41:55 -0400 Message-ID: Subject: Re: How to submit JSON data as request body in Apache CXF jax-rs (REST) From: Benson Margulies To: users@cxf.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 wrote= : > Thanks, that worked. > > But now, if I want to post List of Customers in JSON in the following way= : > > =C2=A0 =C2=A0@POST > =C2=A0 =C2=A0@Path("/addCustomers/") > =C2=A0 =C2=A0@Consumes(MediaType.APPLICATION_JSON) > =C2=A0 =C2=A0//{"Customer":[{"id":2999,"name":"Som Awasthi"},{"id":3000,"= name":"Arnav > Awasthi"}]} > =C2=A0 =C2=A0public List addCustomers(List list){ > =C2=A0 =C2=A0 =C2=A0 =C2=A0logger.debug(list); > =C2=A0 =C2=A0 =C2=A0 =C2=A0return list; > =C2=A0 =C2=A0} > > 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: > > =C2=A0 =C2=A0@GET > =C2=A0 =C2=A0@Path("/listCustomers") > =C2=A0 =C2=A0public List listCustomers(){ > =C2=A0 =C2=A0 =C2=A0 =C2=A0List list =3D new ArrayList(); > =C2=A0 =C2=A0 =C2=A0 =C2=A0list.add(new Customer("Som Awasthi", 2999L)); > =C2=A0 =C2=A0 =C2=A0 =C2=A0list.add(new Customer("Arnav Awasthi", 3000L))= ; > > =C2=A0 =C2=A0 =C2=A0 =C2=A0return list; > =C2=A0 =C2=A0} > > Regards, > Arnav-- > View this message in context: http://cxf.547215.n5.nabble.com/How-to-subm= it-JSON-data-as-request-body-in-Apache-CXF-jax-rs-REST-tp4361669p4362318.ht= ml > Sent from the cxf-user mailing list archive at Nabble.com. >