https://github.com/manzanit0/httpex
Apex library for HTTP callouts.
https://github.com/manzanit0/httpex
apex http rest-api salesforce
Last synced: 24 days ago
JSON representation
Apex library for HTTP callouts.
- Host: GitHub
- URL: https://github.com/manzanit0/httpex
- Owner: manzanit0
- License: apache-2.0
- Created: 2018-06-28T15:02:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-14T07:56:36.000Z (over 6 years ago)
- Last Synced: 2025-01-30T09:41:52.284Z (12 months ago)
- Topics: apex, http, rest-api, salesforce
- Language: Apex
- Size: 14.6 KB
- Stars: 12
- Watchers: 2
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```apex
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
```apex
String authEndpoint = "https://website.com/api/v1/auth"
String endpoint = "https://website.com/api/v1/endpoint2"
Map authParameters = new Map{
'clientId' => 'clientId_value',
'clientSecret' => 'clientSecret_value'
};
OAuthProvider provider = new OAuthProvider(authUrl, authParameters);
HttpClient client = new HttpClient(provider);
HttpResponse res = client.get(endpoint);
```
## Deployment