Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my QueryParam returning null

Tags:

java

jax-rs

Disclaimer : I am not a J2EE developer. But this code works elsewhere, but this one api is going crazy.

Code

@GET
    @Path("GetCloseby")
    @Consumes({ MediaType.TEXT_PLAIN })
    @Produces({ MediaType.APPLICATION_JSON })
    public CServiceCenters getList(@QueryParam("latitude") Double latitude,
            @QueryParam("longitude") Double longitude) {
            log.info("GetCloseby searching for lat "
                    + latitude + " lng " + longitude);

GetCloseby searching for lat 17.63 lng null

Calling from client

curl http://:8080/MYWAR/MYAPI/GetCloseby?latitude=17.63&longitude=73.9

like image 279
Siddharth Avatar asked Jun 24 '26 11:06

Siddharth


1 Answers

Disclaimer: I am not a big cURL user, so I don't know all the nuances, and why this works. It may be a shell problem.

To get it work I had to add quotes " around the url

curl "http://:8080/MYWAR/MYAPI/GetCloseby?latitude=17.63&longitude=73.9"

Note: I also tried to escape the & (without the quotes) but I would get a URISyntaxExeption with the server.

like image 106
Paul Samsotha Avatar answered Jun 26 '26 01:06

Paul Samsotha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!