Creates a HTTPRequest that represents an HTTP request to
the specified URL with the specified HTTP method (GET, POST, etc)
and the specified FetchOptions.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003e\u003ccode\u003eHTTPRequest\u003c/code\u003e is a class that represents a single HTTP request made via the \u003ccode\u003eURLFetchService\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt offers constructors to create requests with a specified URL, HTTP method (like GET or POST), and \u003ccode\u003eFetchOptions\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can add or set headers to the request using \u003ccode\u003eaddHeader\u003c/code\u003e and \u003ccode\u003esetHeader\u003c/code\u003e, and retrieve them via \u003ccode\u003egetHeaders\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eHTTPRequest\u003c/code\u003e class allows setting and retrieving the payload for the request using \u003ccode\u003esetPayload\u003c/code\u003e and \u003ccode\u003egetPayload\u003c/code\u003e, respectively.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to access the HTTP method (\u003ccode\u003egetMethod\u003c/code\u003e) and the URL (\u003ccode\u003egetURL\u003c/code\u003e) associated with the request, as well as the fetch options via \u003ccode\u003egetFetchOptions\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Class HTTPRequest (2.0.0)\n\n public class HTTPRequest implements Serializable\n\n`HTTPRequest` encapsulates a single HTTP request that is made\nvia the `URLFetchService`. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e HTTPRequest \n\nImplements\n----------\n\n[Serializable](https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html) \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nConstructors\n------------\n\n### HTTPRequest(URL url)\n\n public HTTPRequest(URL url)\n\nCreates a `HTTPRequest` that represents a GET request to\nthe specified URL.\n\n### HTTPRequest(URL url, HTTPMethod method)\n\n public HTTPRequest(URL url, HTTPMethod method)\n\nCreates a `HTTPRequest` that represents an HTTP request to\nthe specified URL with the specified HTTP method (GET, POST, etc).\n\n### HTTPRequest(URL url, HTTPMethod method, FetchOptions fetchOptions)\n\n public HTTPRequest(URL url, HTTPMethod method, FetchOptions fetchOptions)\n\nCreates a `HTTPRequest` that represents an HTTP request to\nthe specified URL with the specified HTTP method (GET, POST, etc)\nand the specified [FetchOptions](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.urlfetch.FetchOptions).\n\nMethods\n-------\n\n### addHeader(HTTPHeader header)\n\n public void addHeader(HTTPHeader header)\n\nAdds `header` to this request. If an `HTTPHeader` with the same `name`\nalready exists for this request, it's values are merged with `header`.\n\n### getFetchOptions()\n\n public FetchOptions getFetchOptions()\n\nGet the fetch options for this request.\n\n### getHeaders()\n\n public List\u003cHTTPHeader\u003e getHeaders()\n\nReturns an immutable `List` of `HTTPHeader` objects\nthat have been added to this request.\n\n### getMethod()\n\n public HTTPMethod getMethod()\n\nGets the HTTP method for this request (GET, POST, etc).\n\n### getPayload()\n\n public byte @Nullable [] getPayload()\n\nGets the payload (such as POST body) for this request. Certain HTTP\nmethods (e.g. GET) will not have any payload, and this method\nwill return null.\n\n### getURL()\n\n public URL getURL()\n\nGets the URL for this request.\n\n### setHeader(HTTPHeader header)\n\n public void setHeader(HTTPHeader header)\n\nSets an `HTTPHeader` for this request. If an\n[HTTPHeader](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.urlfetch.HTTPHeader) with the same `name`\nalready exists, its value is replaced.\n\n### setPayload(byte\\[\\] payload)\n\n public void setPayload(byte[] payload)\n\nSets the payload for this request. This method should not be\ncalled for certain HTTP methods (e.g. GET)."]]