Set up for Pardot API calling from Salesforce

June 15, 2023


 

 

In this blog post, we talk about pardot API calling from salesforce

After completing this unit, you’ll be able to:

 

Step 1: Create Connected App

 

 

 

 

 

CallBack URL: https://www.getpostman.com/oauth2/callback

Click the Checkbox | Require Secret for Web Server Flow

 

 

 

Step 2: Manage Connected Apps

 

 

Step 3: Generate Access Token Via Postman

We will Generate Access Token through Postman.

follow the below steps to generate a token:- 

 

 

 

 

 

 

 

Apex Code to Call Pardot API from Salesforce.

 
public class PardotApiDemo {
   
    public void getPardotData(){
       
        HttpRequest req = new HttpRequest();
        req.setHeader(Content-Type, application/x-www-form-urlencoded);
        req.setHeader(Authorization, Bearer <ACCESS TOKEN>); // mention your Access Token
        req.setHeader(Pardot-Business-Unit-Id, <BUSINESS UNIT ID>);// mention your business unit id        
        req.setEndpoint( 'https://pi.demo.pardot.com/api/email/version/4/do/send/prospect_id/23123123');
        req.setMethod( 'POST' );      
        req.setBody('campaign_id=5678&from_name=A Marketer&from_email=marketing@company.com&name=An Email&subject=A Subject&text_content=text email body %%unsubscribe%%&html_content=<html><head><head/><body>html email body %%unsubscribe%%</body></html>');
        HttpResponse res = new Http().send( req );        
        System.debug( res.getStatus() );
        System.debug( res.getBody() );
  }
}

 

I hope this blog helped you!

 

#salesforce #salesforcedeveloper

#salesforcepardotapi #salesforcelightning #salesforcehelp