API_CallCurrentOrg
Class · Group: Web Services
Learn it: Web Services guide
global virtual inherited sharing class API_CallCurrentOrg extends API_OutboundExtends: API_Outbound
Base API class for all handlers that call the current Org standard APIs. Uses session-ID-based authentication and resolves the org base URL dynamically via URL.getOrgDomainURL(). A call to your own org's domain needs neither a Remote Site Setting nor a Named Credential (a stored, reusable connection definition): the platform allows it, and the session id signs it.
Example
global class API_OrgMetadata extends API_CallCurrentOrg
{
global override void configure()
{
super.configure();
requestPayload = new DTO_Request();
responsePayload = new DTO_Response();
}
}Methods
| Method | Description |
|---|---|
| global virtual override void configure() | Initialises the handler and sets the base URL to the current org domain. |
| global virtual override String getAuthorisationToken() | Will return the current session Id as authorisation token. |
| global virtual override String getWebServiceEndPoint() | Constructs the full endpoint URL by combining the current org domain URL with the endpoint path from ApiSetting__mdt configuration. |
configure
global virtual override void configure()Initialises the handler and sets the base URL to the current org domain.
Example
global override void configure()
{
super.configure();
requestPayload = new DTO_Request();
}getAuthorisationToken
global virtual override String getAuthorisationToken()Will return the current session Id as authorisation token.
Returns String — Authorisation Header value
Example
global class API_OrgMetadata extends API_CallCurrentOrg
{
// Uses inherited getAuthorisationToken() which returns 'Bearer <sessionId>'
// to authenticate against the current org's REST API
}getWebServiceEndPoint
global virtual override String getWebServiceEndPoint()Constructs the full endpoint URL by combining the current org domain URL with the endpoint path from ApiSetting__mdt configuration.
Returns String — The full URL endpoint for the web service
Example
// With EndpointPath__c = '/services/data/v{0}/sobjects/StreamingChannel/{1}/push'
// Returns: 'https://myorg.my.salesforce.com/services/data/v{0}/sobjects/StreamingChannel/{1}/push'