Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

Here's an excerpt from Live HTTP headers, I've replaced several values for anonymity.

POST blah/admin.php?module_id=1&action=update&id=129&pageNum=17&&eid=362 HTTP/1.1  Host: blah  User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101027 Firefox/3.6.12  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8  Accept-Language: en-us,en;q=0.5  Accept-Encoding: gzip,deflate  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7  Keep-Alive: 115  Connection: keep-alive  Referer: blah  Cookie: blah  Content-Type: multipart/form-data; boundary=---------------------------21278813472729408841849703914  Content-Length: 5110  -----------------------------21278813472729408841849703914  Content-Disposition: form-data; name="MAX_FILE_SIZE"    300000000 

This request has both GET and POST values. The script on the other end of this is PHP and expects certain values to be in the GET and others to be in the POST.

I know how to issue a GET

curl -G -d "key=val" "http://yadayadayada" 

And I understand how to do a POST

curl -d "key=val" "http://yadayadayada" curl -F "key=val" "http://yadayadayada" 

But how do I mix the two in a single request? Every attempt I've made so far has ended in an error.

like image 940
Fred Avatar asked Nov 04 '10 21:11

Fred


People also ask

Can we use GET and POST together?

The question is, can you use GET and POST method together to create different dynamic pages from a single script? The answer is yes!

How use GET and POST method at the same time?

You can't GET and POST at the same time, they're two different HTTP methods. You're either making a GET request or a POST request to a URL. If you need to scrape data from an external data source, then that's a GET.

Can you POST data with a GET request?

GET is an HTTP method for requesting data from the server. Requests using the HTTP GET method should only fetch data, cannot enclose data in the body of a GET message, and should not have any other effect on data on the server.

Can we pass parameters in POST request?

In this parameter, i.e., is the key and, UTF-8 is the key-value. Enter the same URL in the Postman text field; you will get the multiple parameters in the Params tab. Even you can write each of the parameters and send a request with multiple parameters.


1 Answers

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.

like image 164
Samuel Avatar answered Sep 19 '22 17:09

Samuel