users@jersey.java.net

RE: [Jersey] 400 Bad Request (bug?)

From: Herak Sen <HSen_at_vertrax.com>
Date: Tue, 22 Sep 2009 10:12:54 -0400

Can you double check the path?
If '/project' is the root resource then the '/vulnerabilities/new' is the sub resource, therefore the method ('post') will need @Path("{projectId}/vulnerabilities/new") annotation

Herak

From: Jordi Domingo [mailto:noseya_at_hotmail.com]
Sent: Tuesday, September 22, 2009 8:57 AM
To: users_at_jersey.dev.java.net
Subject: RE: [Jersey] 400 Bad Request (bug?)

I cant understand why its happening this.. in other places i make requests like the one that fails and work fine

POST /projects/1/assets HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; es-ES; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)
Accept: application/json, text/javascript, */*
Accept-Language: ca,en-us;q=0.7,it;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Proxy-Connection: keep-alive
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer: http://localhost/projects/1/assets/new
Cookie: JSESSIONID=1bb45c8173eba1145cf57e0ed37e
Pragma: no-cache
Cache-Control: no-cache
Content-Length: 31

environment=&url=&ip=&hostname=

Response is 200 OK

My Java method is declared this way (but the request didnt reach my code):
@POST
@Produces({"application/json"})
public Response post(@Context UriInfo uriInfo, @PathParam("projectId") int projectId, @FormParam("identifier") String identifier,
                                                          @FormParam("usersId") Long usersId, @FormParam("statusId") Integer statusId, @FormParam("weaknessesId") Integer weaknessesId,
                                                          @FormParam("name") String name, @FormParam("description") String description, @FormParam("consequences") String consequences,
                                                          @FormParam("mitigations") String mitigations, @FormParam("cvssBase") java.math.BigDecimal cvssBase,
                                                          @FormParam("cvssTemporal") java.math.BigDecimal cvssTemporal, @FormParam("cvssEnvironment") java.math.BigDecimal cvssEnvironment,
                                                          @FormParam("standardProvidersCodesId") Long standardProvidersCodesId, @FormParam("visibility") String visibility,
                                                         @FormParam("severity") Integer severity, @FormParam("difficulty") Integer difficulty, @FormParam("probability") Integer probability,
                                                          @FormParam("risk") Integer risk) throws SystemException{
....
}

Any help is appreciated.

________________________________
From: noseya_at_hotmail.com
To: users_at_jersey.dev.java.net
Date: Tue, 22 Sep 2009 13:50:08 +0200
Subject: [Jersey] 400 Bad Request (bug?)

Hi all :)

I'm getting this error, and i think that is a bug. This is my request:

POST /projects/1/vulnerabilities HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; es-ES; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)
Accept: application/json, text/javascript, */*
Accept-Language: ca,en-us;q=0.7,it;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Proxy-Connection: keep-alive
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer: http://localhost/projects/1/vulnerabilities/new
Cookie: JSESSIONID=16f95e59d3b1b0e954310c190c60
Content-Length: 161

identifier=identifier&usersId=1&statusId=1&weaknessesId=4&name=name&description=description&visibility=I&standardProvidersCodesId=&severity=2&difficulty=2&risk=1

THe response is 400 Bad Request.

What you see in bold is causing the bad request. Take it out and works fine.

Thanks,

Jordi

________________________________
Charlas más divertidas con el nuevo Windows Live Messenger<http://download.live.com>

________________________________
Comparte tus fotos con tus amigos. Más fácil con Windows Live<http://download.live.com>