Reputation:
I'm programming in Java. I developed a test web service in which I pass a random json and the service returns me hello
Here the web service code:
@Path("test")
@GET
@Consumes(MediaType.APPLICATION_JSON)
public String test(@HeaderParam("token") String token, @QueryParam("array")String array)
{
return "hello";
}
I call the service with curl
curl -v -H 'token:aaaa' 'http://140.145.1.2/clayapi/restservices/test?array=[{"name":"george","lastname":"ronney"}]';
message of error:
curl: (3) [globbing] illegal character in range specification at pos 60
I tried to add -g but it doesn't work .. how should I do?
Upvotes: 1
Views: 69
Reputation: 130867
Use -G
along with --data-urlencode
:
curl -v -G 'http://example.org' \
-H 'header:value' \
--data-urlencode 'array=[{"name":"george","lastname":"ronney"}]'
From the documentation:
-G
,--get
When used, this option will make all data specified with
-d
,--data
,--data-binary
or--data-urlencode
to be used in an HTTPGET
request instead of thePOST
request that otherwise would be used. The data will be appended to the URL with a?
separator. [...]
--data-urlencode <data>
(HTTP) This posts data, similar to the other
-d
,--data
options with the exception that this performs URL-encoding. [...]
Upvotes: 1