June 15, 2023
In this blog post, we talk about pardot API calling from salesforce
CallBack URL: https://www.getpostman.com/oauth2/callback
Click the Checkbox | Require Secret for Web Server Flow
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 Tokenreq.setHeader(Pardot-Business-Unit-Id, <BUSINESS UNIT ID>);// mention your business unit idreq.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