Skip to main content

HS.HC.RESTClient

class HS.HC.RESTClient extends %Library.RegisteredObject

An instance of this class provides a REST client wrapper around %Net.HttpRequest. There are the following factory methods that create an instance:

In all cases, the URL is considered the "base" url of the REST api and all requests can be invoked using a relative URL. The Client object is intended to be used to make all REST calls to a given REST services endpoint.

Property Inventory

Method Inventory

Properties

property HttpResponse as %Net.HttpResponse [ Calculated ];
property HttpStatus [ Calculated ];
The Return Status code (empty before the request is made)
Property methods: HttpStatusDisplayToLogical(), HttpStatusIsValid(), HttpStatusLogicalToDisplay(), HttpStatusLogicalToOdbc(), HttpStatusNormalize()
property LastError as %String;
Last error that occurred when using this client.
Property methods: LastErrorDisplayToLogical(), LastErrorGet(), LastErrorIsValid(), LastErrorLogicalToDisplay(), LastErrorLogicalToOdbc(), LastErrorNormalize(), LastErrorSet()
property RootURL as %String [ Calculated ];
Property methods: RootURLDisplayToLogical(), RootURLIsValid(), RootURLLogicalToDisplay(), RootURLLogicalToOdbc(), RootURLNormalize()

Methods

method Delete(requestPath As %String, options As HS.HC.RESTOptions = "", body="") as %DynamicObject
@API.Method
Invoke an Http DELETE
requestPath - The path for the REST call. The base URL for the Gateway API endpoint will be prepended.
params - Multi-dimensional array of name-value pairs to be added to the URL as query parameters
classmethod FromHTTPService(nameOrEntry As %String, resourceName As %String = "", options As HS.HC.RESTOptions = "") as HS.HC.RESTClient
@API.Method
Creates a client to an HTTP endpoint. The input can be the name of an HTTP Service Registry entry, or the ServiceRegistry entry itself. The HTTPCredentialsConfig property of the HTTP Service (if non-null)
classmethod FromURL(url As %String, sslConfig As %String = "", options As HS.HC.RESTOptions = "") as HS.HC.RESTClient
@API.Method
Creates a client to an endpoint at a specified URL. By default there is no authorization set up for the returned RESTClient instance. Use one of the authorization methods; SetBasicAuth(), SetBearerToken(), or SetCredentialByName() to specify how the client should authorize itself.
method Get(requestPath As %String, options As HS.HC.RESTOptions = "") as %DynamicObject
@API.Method
Invoke an Http GET
requestPath - The path for the REST call. The base URL for the Gateway API endpoint will be prepended.
params - Multi-dimensional array of name-value pairs to be added to the URL as query parameters
method HttpResponseGet() as %Net.HttpResponse
method HttpStatusGet() as %Integer
method Patch(requestPath As %String, options As HS.HC.RESTOptions = "", body="") as %DynamicObject
@API.Method
Invoke an Http PATCH
requestPath - The path for the REST call. The base URL for the Gateway API endpoint will be prepended.
params - Multi-dimensional array of name-value pairs to be added to the URL as query parameters
body (optional) - The body portion of the request. May be empty, or one of: %Stream.Object, %DynamicAbstractObject, %JSON.Adaptor, %String
method Post(requestPath As %String, options As HS.HC.RESTOptions = "", body="") as %DynamicObject
@API.Method
Invoke an Http POST
requestPath - The path for the REST call. The base URL for the Gateway API endpoint will be prepended.
params - Multi-dimensional array of name-value pairs to be added to the URL as query parameters
body (optional) - The body portion of the request. May be empty, or one of: %Stream.Object, %DynamicAbstractObject, %JSON.Adaptor, %String
method Put(requestPath As %String, options As HS.HC.RESTOptions = "", body="") as %DynamicObject
@API.Method
Invoke an Http PUT
requestPath - The path for the REST call. The base URL for the Gateway API endpoint will be prepended.
params - Multi-dimensional array of name-value pairs to be added to the URL as query parameters
body (optional) - The body portion of the request. May be empty, or one of: %Stream.Object, %DynamicAbstractObject, %JSON.Adaptor, %String
method Request(verb As %String, requestPath As %String, options As HS.HC.RESTOptions = "", body="") as %DynamicAbstractObject
@API.Method
Generic HTTP Request method. Returns a %DynamicAbstractObject by parsing the response body. Any errors, if not thrown are returned as JSON with a single key: "non-json-result".

verb - The Http Verb for this request (GET, POST, etc)
requestPath - The path for the REST call. The base URL for the Gateway API endpoint will be prepended.
params - Multi-dimensional array of name-value pairs to be added to the URL as query parameters
body (optional) - The body portion of the request. May be empty, or one of: %Stream.Object, %DynamicAbstractObject, %JSON.Adaptor, %String
method ResetAuthorization()
@API.Method
Clears the authorization configured for the RESTClient. Use this to indicate a request with no credentials
method RootURLGet() as %String
method SetBasicAuth(username As %String, password As %String)
@API.Method
Sets username and password that will be provided in the AUTHORIZATION header of each request
method SetBearerToken(token As %String)
@API.Method
Sets a bearer token that will be provided in the AUTHORIZATION header of each request
method SetCredentialByName(credentialName As %String)
@API.Method
Specifies that name of an Ens.Config.Credentials that holds the username and password to be provided in the AUTHORIZATION header of each request

Inherited Members

Inherited Methods

FeedbackOpens in a new tab