RESTMessageV2 - setAuthenticationProfile(String type, String profileId)

Set the credentials for the REST message using an existing basic auth or OAuth 2.0 profile.

Table 1. Parameters
Name Type Description
type String The type of authentication profile to use. Valid values are 'basic' to use basic authentication, or 'oauth2' to use OAuth 2.0.
profileId String The sys_id of an authentication profile record. When using basic auth, specify the sys_id of a Basic Auth Configuration [sys_auth_profile_basic] record. When using OAuth 2.0, specify the sys_id of a OAuth Entity Profile [oauth_entity_profile] record.
Table 2. Returns
Type Description
var requestBody;
var responseBody;
var status;
var sm;
       // Might throw exception if message doesn't exist or not visible due to scope.
	sm = new sn_ws.RESTMessageV2("Yahoo Finance", "get");  

       //set auth profile to an OAuth 2.0 profile record.
	sm.setAuthenticationProfile('oauth2', '1234adsf123212131123qasdsf'); 

	sm.setStringParameter("symbol", "NOW");
       //In milliseconds. Wait at most 10 seconds for response from http request.

       //Might throw exception if http connection timed out or some issue with sending
       //request itself because of encryption/decryption of password.
	response = sm.execute();	
       responseBody = response.haveError() ? response.getErrorMessage() : response.getBody();
	status = response.getStatusCode();
} catch(ex) {
	responseBody = ex.getMessage();
	status = '500';
} finally {
	requestBody = sm ? sm.getRequestBody():null;