Is passing parameters in the Header Section of HTTP GET possible? Passing parameters in the requested URL is one way of passing parameters. Is there any other way to do the same?
1 Answers
Yes, it is absolutely possible to add custom headers to an HTTP GET (or indeed any HTTP request), and for the server to pick them up.
Historically, these were prefixed with "X-", e.g. "X-My-Custom-Value". However, from reading the answers to "Custom HTTP headers : naming conventions" this was an old recommendation which is now deprecated.
Before you do anything like this, though, think carefully about what you're trying to achieve. Why are you using GET rather than POST?
If, for instance, it's so the request is bookmarkable, any bookmarking of the URL will not include the custom headers.
If you're trying to be RESTful - e.g., this operating involves getting something, so you think you should use the GET verb - then you're significantly violating normal, expected behaviour in your attempt to make your request behave in a manner you think would be normal and expected.
POST is there for a reason. Don't try to use GET to do the job of POST unless you have a really good reason.

- 1
- 1

- 4,215
- 2
- 24
- 38
-
I am writing a WCF Rest service to read the HTTP get request and send a response. What my client wants is: "As our API is a "RESTful" service we should be able to use both GET and POST with same method. The parameter can be placed in the URL of a GET request and also in the Header section of the GET request. When using a HTTP POST with this method the parameter can be stored in the header section or the body." – Arti Feb 05 '14 at 06:50
-
user16505891: your client seems to be confused. If this is *really* about being "restful" then all methods should use the same URI, not extension header fields. – Julian Reschke Feb 05 '14 at 08:20
-
1@user1650891 - well, if a paying client really, really wants it, even after you explain that it's not the normal or accepted way to build a RESTful service, I guess you shrug and give them an estimate that's twice as expensive as doing it properly. – Carson63000 Feb 05 '14 at 22:15