Skip to content

manzanit0/Httpex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Httpex

Apex library for HTTP callouts

Getting started

The library was designed for ease of use. Depending on the authentication scheme used by the destination endpoint, it's as easy as picking the appropiate provider:

BASIC example

String basicUser = "myuser"
String basicPassword = "12345"
String endpoint = "https://website.com/api/v1/endpoint1"

BasicProvider provider = new BasicProvider(basicUser, basicPassword)
HttpClient client = new HttpClient(provider);
HttpResponse res = client.post(endpoint, "{\"data\": \"something\"}")

OAuth2 example

String authEndpoint = "https://website.com/api/v1/auth"
String endpoint = "https://website.com/api/v1/endpoint2"
Map<String, String> authParameters = new Map<String, String>{
    'clientId' => 'clientId_value',
    'clientSecret' => 'clientSecret_value'
};

OAuthProvider provider = new OAuthProvider(authUrl, authParameters);
HttpClient client = new HttpClient(provider);
HttpResponse res = client.get(endpoint);

Deployment

Deploy to Salesforce

Releases

No releases published

Packages

No packages published

Languages