GET Requests
httpGet
Performs an HTTP GET request and returns the server’s response.The full URL to request (e.g.,
"https://api.example.com/users")Optional HTTP headers (variadic). Each header should be a string in the format
"Key: Value"Returns the response body as a string, or
undefined if the request failsExample: Fetching data
Example: With custom headers
POST Requests
httpPost
Performs an HTTP POST request with a request body.The full URL to request
The request body (typically JSON or form data)
Optional HTTP headers (variadic)
Returns the response body as a string, or
undefined if the request failsIf no
Content-Type header is provided, it defaults to application/json.Example: Sending JSON data
Example: With authentication
PUT Requests
httpPut
Performs an HTTP PUT request to update a resource.The full URL to request
The request body
Optional HTTP headers (variadic)
Returns the response body as a string, or
undefined if the request failsExample: Updating a resource
PATCH Requests
httpPatch
Performs an HTTP PATCH request to partially update a resource.The full URL to request
The request body
Optional HTTP headers (variadic)
Returns the response body as a string, or
undefined if the request failsExample: Partial update
DELETE Requests
httpDelete
Performs an HTTP DELETE request to remove a resource.The full URL to request
Optional request body
Optional HTTP headers (variadic)
Returns the response body as a string, or
undefined if the request failsExample: Deleting a resource
Generic HTTP Request
httpRequest
Performs an HTTP request with any custom method.The HTTP method (e.g.,
"GET", "POST", "HEAD", "OPTIONS")The full URL to request
Optional request body
Optional HTTP headers (variadic)
Returns the response body as a string, or
undefined if the request failsExample: Custom method
Deprecated Function
httpPostRequest
Legacy HTTP POST request function.The hostname or IP address
The port number
The request path
The POST data
Whether to receive a response (1 = yes, 0 = no). Default: 1
Best Practices
Use HTTPS
Always use HTTPS URLs for secure communication. SSL verification is disabled by default.
Handle Errors
Always check if the response is
undefined before using it.Escape JSON
Properly escape quotes in JSON strings using backslashes.
Async Behavior
HTTP requests are synchronous and will block script execution. Keep requests fast.
Complete Example
Example: Player authentication system