How can I make a request with both GET and POST parameters? How can I make a request with both GET and POST parameters? curl curl

How can I make a request with both GET and POST parameters?


GET variables can be included in the URL. You just include the GET variables in the query string. For example, if you wanted to send a GET request with "username=fred" to www.example.com/index.php, you would send a simple GET request to "http://www.example.com/index.php?username=fred". So to answer your question, just use the POST method, but have the URL contain your GET data.


To clarify, GET and POST are HTTP request methods, not value types.

  • GET variables are called query string parameters. They are part of the URL, and can be included in any request.
  • POST variables are the contents of a urlencoded message body. These might also be sent with a PUT request.

Therefore, if you want to send both types of values, send the POST data as normal while explicitly writing your query string.

curl -d "key=val" "http://example.com?query_var=1"