API: client
Source:
http/client.ts
Provides a JavaScript/TypeScript wrapper (Facade) for making synchronous HTTP requests.
Usage
import { client, response } from "sdk/http";
const httpResponse = client.get("https://services.odata.org/V4/Northwind/Northwind.svc/");
response.println(httpResponse.statusMessage);
response.println(httpResponse.text);
response.flush();
response.close();Classes
HttpClient
A static class providing methods for making synchronous HTTP requests.
All methods call the underlying Java Facade and parse the JSON response.
Methods
get
get (url:string, options:HttpClientRequestOptions={}):HttpClientResponseExecutes a synchronous HTTP GET request.
@param url The target URL.
@param options Configuration options for the request.
@returns The parsed response object containing status, headers, and body.
post
post (url:string, options:HttpClientRequestOptions={}):HttpClientResponseExecutes a synchronous HTTP POST request.
@param url The target URL.
@param options Configuration options for the request, including request body intextordata.
@returns The parsed response object.
put
put (url:string, options:HttpClientRequestOptions={}):HttpClientResponseExecutes a synchronous HTTP PUT request.
@param url The target URL.
@param options Configuration options for the request.
@returns The parsed response object.
patch
patch (url:string, options:HttpClientRequestOptions={}):HttpClientResponseExecutes a synchronous HTTP PATCH request.
@param url The target URL.
@param options Configuration options for the request.
@returns The parsed response object.
delete
delete (url:string, options:HttpClientRequestOptions={}):HttpClientResponseExecutes a synchronous HTTP DELETE request.
@param url The target URL.
@param options Configuration options for the request.
@returns The parsed response object.
del
del (url:string, options:HttpClientRequestOptions={}):HttpClientResponseAlias for {@link HttpClient.delete}. Executes a synchronous HTTP DELETE request.
@param url The target URL.
@param options Configuration options for the request.
@returns The parsed response object.
head
head (url:string, options:HttpClientRequestOptions={}):HttpClientResponseExecutes a synchronous HTTP HEAD request (fetches headers only).
@param url The target URL.
@param options Configuration options for the request.
@returns The parsed response object. The body (textanddata) will typically be empty.
trace
trace (url:string, options:HttpClientRequestOptions={}):HttpClientResponseExecutes a synchronous HTTP TRACE request.
@param url The target URL.
@param options Configuration options for the request.
@returns The parsed response object.
buildUrl
buildUrl (url:string, options:HttpClientRequestOptions):string@private
Builds the request URL by appending query parameters from options.params,
then removesparamsfrom the options object before passing it to the Java Facade.
@param url The base URL.
@param options The request options object.
@returns The URL with appended query parameters.