users@jersey.java.net

POST to RESTful services written using Jersey API

From: Rameswara Sashi Kiran Challa <schalla_at_umail.iu.edu>
Date: Wed, 17 Mar 2010 23:30:48 -0400

Hi..

Could someone please tell me what I am doing wrong in here.

I am trying to write a simpe shell script in which I am calling the RESTful
services that I have written using Jersey API. I am trying to call these
services without using the Jersey Client API. I had earlier written a client
using Jersey API and it all worked fine. Now I am trying to do simple curl
Post to my service. The error(HTTP status 415) I get suggests that I am
doing something wrong in specifying the Media Types.

With Jersey Client API I got it working like this:
String gaussianoutput = webResource2.accept(*MediaType.TEXT_PLAIN_TYPE*,*
MediaType.APPLICATION_XML_TYPE*).type(*MediaType.APPLICATION_XML_TYPE*
).post(String.class,s);

What Media Types or Content0Type should I be specifying while using curl ??
If anybody has already figured out please help me out

*Here is my shell script calling service 1*:

abc=`curl http://gf18...:8080/InChIto3D/inchi/3dstructure?InChIstring=$inchi`
         //returns an xml string

echo $abc //this works fine.

*Passing(Posting) this $abc to service 2*

def=`curl -d $abc -H "Content-Type:text/xml" http://gf18...:8080
/CML2Gauss/cml3d/gaussinput`

Error I get:
....
....
<h1>*HTTP Status 415* - </h1><HR size="1" noshade="noshade"><p><b>type</b>
Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>*The
server refused this request because the request entity is in a format not
supported by the requested resource for the requested method ().*</u></p><HR
size="1" noshade="noshade"><h3>Apache Tomcat/6.0.26</h3></body></html>



Thanks a lot

Regards


-- 
Sashikiran Challa
MS Cheminformatics,