REST - Body Parameters in POST Method

Posted by terlas on 21-May-2013 07:14

Hi,

I have defined two REST methods, GET and POST (See images attached).

GET it's working fine and response is OK. The problem is in POST because of web parameters. I'm using restClient for Firefox.

This is the wadl.

<application xmlns="http://wadl.dev.java.net/2009/02" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<grammars/>
<resources base="http://10.250.0.220:8080/Project/rest/Producte">
<resource path="/Producte">
<method name="GET">
<request>
<param name="piCodProd" style="query" default="" type="xs:string"/>
</request>
<response status="204"/>
</method>
<method name="POST">
<response status="204"/>
</method>
</resource>
</resources>
</application>

I'm trying to call service via POST method with the URL "http://{myIP}:8080/Project/rest/Producte/Producte", and in Body:

{pcNamProd:"ProductOne"}

This should be insert de "ProductOne" Product in database but I have this error.

  1. Status Code: 415 Unsupported Media Type
  2. Content-Length: 0
  3. Date: Tue, 21 May 2013 12:09:34 GMT
  4. Server: Apache-Coyote/1.1

Can anyone tell me what I'm doing wrong?

Tx!!

Mapping_GET.jpg

Mapping_POST.jpg

All Replies

Posted by bronco on 06-Aug-2013 09:34

I'm running into the same problem, the "415, unsupported media type". Did you solve it somehow?

I get this when I want to test my REST service from PostMan, which is a Chrome app for HTTP calls.

Posted by Peter Judge on 06-Aug-2013 09:39

Is the Content-Type header set correctly to application/json?

Posted by bronco on 06-Aug-2013 10:00

I thought the tool did, but apparently not. Setting the Content-Type header "manually" did he trick. Thanks!

This thread is closed