Bankelaal Bankelaal - 1 year ago 134
reST (reStructuredText) Question

How to pass JSON as a query parameter in a HTTP request?

I am using RESTEasy stack to implement a REST based client and server. I have a service which handles

request, like below:

public String testPost(@QueryParam("thing") String thing) {

When I call from Postman or REST client the following URI:


I always get the error as Illegal character in query at index (pointing to =)

What is the reason for this?

Answer Source

If you're trying to parse a POST request, you should use @FormParam instead of @QueryParam. Then, you can make the post request doing something like this (using curl)

curl -i -X POST -H "Content-Type: application/json" -d thing="{\"id\":\"abc\"}" http://ip:port/base/this
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download