function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Damien_2Damien_2 

Help with Apex Web Callout

I'm working with an external System that has a 'Shared Secret' and provides a URL for the different callouts.  I'm not quite sure where to use the secret that I have created with the external system.  I'm not sure what else to add to what I have below.  Could anyone give me a little guidance or help please?

 

public class CaseSearchController
{
	public List<Case> calloutCases{get;set;}
	private String endPoint = 'my endpoint is here';
	private String secret = 'my secret is here';
	
	public CaseSearchController()
	{
		init();
	}
	
	private void init()
	{
		getCases();
	}
	
	private void sendCases()
	{
		HttpRequest req = new HttpRequest();
		HttpResponse res = new HttpResponse();
		Http http = new Http();

		req.setEndpoint(endPoint);
		req.setMethod('GET');
		req.setCompressed(true);

		try
		{
			res = http.send(req);
			System.debug('res = ' + res);
		} catch(System.CalloutException e)
		{
			System.debug('Callout error: '+ e);
			System.debug(res.toString());
		}
	}
}

 

Ritesh AswaneyRitesh Aswaney

It seems like a candidate for an HTTP Request Header - you will need to read on any samples or documentation that your target system provides

 

eg http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_httprequest.htm

req.setHeader('Authorization', authorizationHeader);