Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Http GET request parameter as query parameter and header

Tags:

java

http

I need to send parameters through HTTP GET request. Since my HTTP client has to be generic, I am adding the parameters as query parameter (?key=value&k=v) and also as request header (key: value).

Is this a good approach? Will the server looking for header ignore query parameters or vice versa?

Please suggest.

like image 709
Ravi Kiran Avatar asked Aug 03 '26 17:08

Ravi Kiran


1 Answers

As per the convention, you should set the request parameter for GET request in the query string. Headers are used for passing message/meta information along with the request. So use headers to set that information only, such as Content-Type,Accept.

Avoid mixing the headers and request params.

like image 167
Juned Ahsan Avatar answered Aug 06 '26 08:08

Juned Ahsan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!