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 three factory methods that create an instance.
FromHTTPService will create a client for the specified HTTP Service Registry entry
FromURL will create a client for the specified url. 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 to the Gateway REST services of a specified gateway. To make REST calls to another Gateway, instantiate this class, providing the "GatewayName" as registered in the Gateway Registry. To create a client instance call
set instance = ##class(HS.Gateway.RESTClient).%New(gatewayName)
The instantiation will throw an exception unless:

Property Inventory

Method Inventory

Properties

property HttpResponse as %Net.HttpResponse [ Calculated ];
Property methods: HttpResponseGet()
property HttpStatus [ Calculated ];
The Return Status code (empty before the request is made)
Property methods: HttpStatusDisplayToLogical(), HttpStatusGet(), 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()

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 = "")
@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 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