aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes How to submit JSON data as request body in Apache CXF jax-rs (REST) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to submit JSON data as request body in Apache CXF jax-rs (REST)" Watch "How to submit JSON data as request body in Apache CXF jax-rs (REST)" New topic
Author

How to submit JSON data as request body in Apache CXF jax-rs (REST)

Arnav Awasthi
Greenhorn

Joined: Apr 30, 2011
Posts: 1
I am using Apache-CXF for creating REST web services and trying to submit a form.

Server:
This is my method, which is expected to get json data.

@POST
@Path("/addCustomer/")
@Consumes(MediaType.APPLICATION_JSON)
//{"Customer":{"name":"Some Name","id":6}}
public Customer addCustomer(Customer customer){
logger.debug(customer);
return customer;
}


Client:
I am using firefox REST plugin for submitting request:
Using REST client, I have posted following json as request body:
{"Customer":{"name":"Arnav Awasthi","id":6}}

But I am getting "415: Unsupported Media Type".
Devi Sri
Ranch Hand

Joined: Dec 20, 2005
Posts: 114

Hi,

Set the response type appropriately.

Regards,


Devisri, SCJP 5.0, SCWCD 5.0
"Dream is Not what you see in sleep. Dream is that which never lets you sleep" - Abdul Kalam
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to submit JSON data as request body in Apache CXF jax-rs (REST)