URL parameters are not being passed by curl POST

前端 未结 3 558
情话喂你
情话喂你 2020-12-11 10:14

This is my java code:

@POST
@Path(\"/sumPost\")
@Produces(MediaType.TEXT_PLAIN)
public String sumPost(@QueryParam(value = \"x\") int x,
        @QueryParam(v         


        
3条回答
  •  悲哀的现实
    2020-12-11 10:32

    You are missing the data part of the command:

    curl --data "param1=value1¶m2=value2" https://example.com/fakesite.php

    The -d (or --data) should come before the link. And the "name value pair" should be varName=varValue&otherVar=otherValue

    Also, from documentation, the -X command is not correct:

    This option only changes the actual word used in the HTTP request, it does not alter the way curl behaves. So for example if you want to make a proper HEAD request, using -X HEAD will not suffice. You need to use the -I, --head option. 
    

    It should be -X POST

    Finally, Remember to use "html encode" to encode your values.

提交回复
热议问题