Click or drag to resize

HTTPClientRequest Method

Sends a request to the connected host. The URL parameter is just the part after the host, so for http://somehost.com/index.php, it is index.php.

Headers are HTTP request headers. For available HTTP methods, see HTTPClientMethod.

To create a POST request with query strings to push to the server, do:

var fields = {"username" : "user", "password" : "pass"}
var query_string = http_client.query_string_from_dict(fields)
var headers = ["Content-Type: application/x-www-form-urlencoded", "Content-Length: " + str(query_string.length())]
var result = http_client.request(http_client.METHOD_POST, "index.php", headers, query_string)

Note: The request_data parameter is ignored if method is . This is because GET methods can't contain request data. As a workaround, you can pass request data as a query string in the URL. See String.http_escape for an example.

Namespace:  Godot
Assembly:  GodotSharp (in GodotSharp.dll) Version: 1.0.0
Syntax
C#
public Error Request(
	HTTPClientMethod method,
	string url,
	string[] headers,
	string body = ""
)

Parameters

method
Type: GodotHTTPClientMethod

[Missing <param name="method"/> documentation for "M:Godot.HTTPClient.Request(Godot.HTTPClient.Method,System.String,System.String[],System.String)"]

url
Type: SystemString

[Missing <param name="url"/> documentation for "M:Godot.HTTPClient.Request(Godot.HTTPClient.Method,System.String,System.String[],System.String)"]

headers
Type: SystemString

[Missing <param name="headers"/> documentation for "M:Godot.HTTPClient.Request(Godot.HTTPClient.Method,System.String,System.String[],System.String)"]

body (Optional)
Type: SystemString

[Missing <param name="body"/> documentation for "M:Godot.HTTPClient.Request(Godot.HTTPClient.Method,System.String,System.String[],System.String)"]

Return Value

Type: Error

[Missing <returns> documentation for "M:Godot.HTTPClient.Request(Godot.HTTPClient.Method,System.String,System.String[],System.String)"]

See Also