global class TriggeredSend {
@future (callout=true)
public static void send(){
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setMethod('POST');
req.setEndpoint('https://www.exacttargetapis.com/messaging/v1/messageDefinitionSends/53d84ecc15ac1b315a0e9-3618-e411-b6d6-b4b52f5cc7b0/send');
// Specify the required user name and password to access the endpoint
// As well as the header and header information
String username = '***';
String password = '***!';
Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'BASIC ' +
EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization', authorizationHeader);
// Create a new http object to send the request object
// A response object is generated as a result of the request
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug('Fulfillment service returned '+ res.getBody());
// Examine the status code from the HTTPResponse
// If status code != 200, write debugging information, done
if (res.getStatusCode() != 200) {
System.debug('Error from ' + req.getEndpoint() + ' : ' +
res.getStatusCode() + ' ' + res.getStatus());
}
else{System.debug('Success!');}
}
}
}
Where 53d84ecc15ac1b315a0e9-3618-e411-b6d6-b4b52f5cc7b0 is a uniquethe object id that I assigned as the customer key to the triggered send Iwas created on Exacttagetwhen I defined a new triggeredsend definition using php code. I am receiving a 401 error (unauthorized), which leads me to believe that the URL I am using is incorrect, but do not know why.