UTIL_HttpClient
Class · Group: Web Services
global inherited sharing class UTIL_HttpClientFluent HTTP client facade over the API_Dispatcher pipeline. Provides zero-boilerplate callouts with automatic retry, circuit breaker, failure logging, performance timing, sensitive data masking, and ApiCall__c lifecycle management — all routed through API_Dispatcher.execute(). Supports two usage modes: Ad-hoc mode: Direct HTTP calls via get()/post()/put()/del()/patch() entry points Delegation mode: Subscriber handlers via useHandler() entry point
Since: 1.0
Example:
HttpResponse response = UTIL_HttpClient.post('PaymentGateway', '/charges')
.body(chargeRequest)
.withRetry(3)
.send();Properties
| Property | Description |
|---|---|
| global enum FailureAction | Defines the action to take when an HTTP call fails. |
Methods
| Method | Description |
|---|---|
| global static UTIL_HttpClient.RequestBuilder del(String credential, String path) | Creates a DELETE request for the specified credential and path. |
| global static UTIL_HttpClient.RequestBuilder get(String credential, String path) | Creates a GET request for the specified credential and path. |
| global static UTIL_HttpClient.RequestBuilder patch(String credential, String path) | Creates a PATCH request for the specified credential and path. |
| global static UTIL_HttpClient.RequestBuilder post(String credential, String path) | Creates a POST request for the specified credential and path. |
| global static UTIL_HttpClient.RequestBuilder put(String credential, String path) | Creates a PUT request for the specified credential and path. |
| global static UTIL_HttpClient.RequestBuilder useHandler(Type handlerType) | Creates a delegation mode request for the specified subscriber handler. |
Inner Classes
| Class | Description |
|---|---|
| RequestBuilder | Fluent builder for configuring and executing HTTP requests through API_Dispatcher. |
Method Details
del
global static UTIL_HttpClient.RequestBuilder del(String credential, String path)Creates a DELETE request for the specified credential and path.
Parameters:
credential(String) - The Named Credential or ApiCredential__mdt DeveloperNamepath(String) - The URL path to append to the endpoint
Returns: UTIL_HttpClient.RequestBuilder - A RequestBuilder for further configuration
Since: 1.0
Example:
HttpResponse response = UTIL_HttpClient.del('CRM', '/contacts/{id}')
.pathParam('id', contactId)
.send();get
global static UTIL_HttpClient.RequestBuilder get(String credential, String path)Creates a GET request for the specified credential and path.
Parameters:
credential(String) - The Named Credential or ApiCredential__mdt DeveloperNamepath(String) - The URL path to append to the endpoint
Returns: UTIL_HttpClient.RequestBuilder - A RequestBuilder for further configuration
Since: 1.0
Example:
HttpResponse response = UTIL_HttpClient.get('CRM', '/accounts/{id}')
.pathParam('id', accountId)
.send();patch
global static UTIL_HttpClient.RequestBuilder patch(String credential, String path)Creates a PATCH request for the specified credential and path.
Parameters:
credential(String) - The Named Credential or ApiCredential__mdt DeveloperNamepath(String) - The URL path to append to the endpoint
Returns: UTIL_HttpClient.RequestBuilder - A RequestBuilder for further configuration
Since: 1.0
Example:
HttpResponse response = UTIL_HttpClient.patch('CRM', '/contacts/{id}')
.pathParam('id', contactId)
.body(patchPayload)
.send();post
global static UTIL_HttpClient.RequestBuilder post(String credential, String path)Creates a POST request for the specified credential and path.
Parameters:
credential(String) - The Named Credential or ApiCredential__mdt DeveloperNamepath(String) - The URL path to append to the endpoint
Returns: UTIL_HttpClient.RequestBuilder - A RequestBuilder for further configuration
Since: 1.0
Example:
HttpResponse response = UTIL_HttpClient.post('EmailService', '/send')
.body(emailPayload)
.send();put
global static UTIL_HttpClient.RequestBuilder put(String credential, String path)Creates a PUT request for the specified credential and path.
Parameters:
credential(String) - The Named Credential or ApiCredential__mdt DeveloperNamepath(String) - The URL path to append to the endpoint
Returns: UTIL_HttpClient.RequestBuilder - A RequestBuilder for further configuration
Since: 1.0
Example:
HttpResponse response = UTIL_HttpClient.put('CRM', '/contacts/{id}')
.pathParam('id', contactId)
.body(contactPayload)
.send();useHandler
global static UTIL_HttpClient.RequestBuilder useHandler(Type handlerType)Creates a delegation mode request for the specified subscriber handler.
Parameters:
handlerType(Type) - The API_Outbound subclass Type to delegate to
Returns: UTIL_HttpClient.RequestBuilder - A RequestBuilder configured for delegation mode
Since: 1.0
Example:
API_Outbound handler = UTIL_HttpClient.useHandler(API_SendEmail.class)
.credential('EmailGateway')
.withParameter(API_SendEmail.PARAM_RECIPIENT, email)
.invoke();