Skip to main content
added 44 characters in body
Source Link
  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.

  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/53d84ecc15ac1/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 53d84ecc15ac1 is a unique id that I assigned as the customer key to the triggered send I created on Exacttaget. 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.

  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/b315a0e9-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 b315a0e9-3618-e411-b6d6-b4b52f5cc7b0 is the object id that was created when 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.

edited body
Source Link
  publicglobal 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/53d84ecc15ac1/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!');}
   }
 }
 }
  public 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/53d84ecc15ac1/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!');}
   }
 }
 }
  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/53d84ecc15ac1/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!');}
   }
 }
 }
added 1741 characters in body
Source Link

The Snippet of the code that I am using to try sending a triggered email from Salesforce is

  public 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/53d84ecc15ac1/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 53d84ecc15ac1 is a unique id that I assigned as the customer key to the triggered send I created on Exacttaget. 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.

The Snippet of the code that I am using to try sending a triggered email from Salesforce is

  public 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/53d84ecc15ac1/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 53d84ecc15ac1 is a unique id that I assigned as the customer key to the triggered send I created on Exacttaget. 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.

Source Link
Loading