415 - Unsupported Media Type in HelloWorld example

2,346 views
Skip to first unread message

Stefan

unread,
Aug 16, 2012, 8:13:40 AM8/16/12
to grails-jax...@googlegroups.com
I downloaded Grails 2.1.0. I did everything exactly as said on 
http://code.google.com/p/grails-jaxrs/wiki/GettingStarted

As stated in section Use the REST API I try to send POST request to create a new user.
POST /hello/api/person HTTP/1.1
Content-Type: application/xml
Accept: application/xml
Host: localhost:8080
Content-Length: 82

<person>
 
<firstName>Sam</firstName>
  <lastName>Hill</
lastName>
</person>

I get an HTTP Status 415 - Unsupported Media Type error. What am I doing wrong?? 
response.html

Martin Krasser

unread,
Aug 16, 2012, 1:48:47 PM8/16/12
to grails-jax...@googlegroups.com
Hi Stefan,

does it work with Grails 2.0.x for you?

Am 16.08.12 14:13, schrieb Stefan:

Stefan

unread,
Aug 20, 2012, 3:53:10 AM8/20/12
to grails-jax...@googlegroups.com
Hi Martin

I just tried with Grails 2.0.4. I get the same 415 Tomcat error.

I'm using ~$ lwp-request -m POST http://localhost:8080/hello/api/person < post.txt

I tried to send the request using the Postman plugin for Google Chrome. There I get a 500 - Internal Server Error error (attachment).
error.html

Martin Krasser

unread,
Aug 21, 2012, 3:29:50 AM8/21/12
to grails-jax...@googlegroups.com
Hi Stefan,

try to specify the content type with lwp-request -c 'application/xml' ... If this doesn't work, I'll take a closer look when I'm back from vacation.

Cheers,
Martin

2012/8/20 Stefan <stefan...@weblaw.ch>
Message has been deleted
Message has been deleted

Stefan

unread,
Aug 21, 2012, 6:22:55 AM8/21/12
to grails-jax...@googlegroups.com, kras...@googlemail.com
I got it now. I just put the XML/JSON part as content.

~$ lwp-request -c 'application/json' -m POST http://localhost:8080/hello/api/person < post.txt

where post.txt only contains
<person>
 
<firstName>Sam</firstName>
  <lastName>Hill</
lastName>
</person>

I had the header too -> 500 - Internal Server Error
POST /hello/api/person HTTP/1.1
Content-Type: application/xml
Accept: application/xml
Host: localhost:8080
Content-Length: 82

<person>
 
<firstName>Sam</firstName>
  <lastName>Hill</
lastName>
</person>

Thx for your help!

Stefan Broder

unread,
Aug 21, 2012, 4:19:56 AM8/21/12
to grails-jax...@googlegroups.com
Hi Martin

Thx for your response. If I specify application/xml I get the same error as with the Postman plugin. I'm having this behavior on an Ubuntu 11.10 and on my OS X (Snow Leopard). Can I give you more information that might help you?

Cheers,
Stefan
--
Freundliche Grüsse
Stefan Broder
BSc in IT, Software Engineer

Weblaw AG
CyberSquare | Laupenstrasse 1 | 3008 Bern Schweiz
T +41 31 380 57 77 | F +41 31 380 57 78
www.weblaw.ch
error.html
Reply all
Reply to author
Forward
0 new messages