I am a new Salesforce developer.
I got an assignment where I have to get connected to an API using developer_id;developer_key
The documentation says,
Developer authentication involved sending a specifically formatted token as a header with your request.
The header is generated with the use of your developer_id and developer key.
The header is comprised like so: Mysite-Developer-Auth-V1: <developer_id>;<developer_key>
The following is a sample of a curl request with a valid auth header:
curl \
-X POST "http://www.Mysite.com/api/users/0.1/self/jobs/" \
-H 'Mysite-Developer-Auth-V1: 12345678;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
-H "Content-Type: application/json" --data '{"jobs[]": [1,2,3]}'
Which is the best method to Authenticate and why:
1. HTTP callout?
2. Or CURL
Note that I have to carry forward the token returned by the API, to execute other functions(API).
How do I pass the header?Here is my incomplete code that I have tried
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('http://www.mysite.com/api/users/0.1/self/jobs/');
request.setMethod('GET');
HttpResponse response = http.send(request);
// If the request is successful, parse the JSON response.
if (response.getStatusCode() == 200) {
//
}