0

I am attempting to make an API call from a Salesforce Marketing Cloud Cloudpage App via SSJS, using Pardot API to determine if an email address exists within Pardot to verify that an email was sent to the specific email address from Pardot.

  1. Customer lands on Cloudpage, and email address is captured
  2. Token is requested from SF Connector App and successfully returned
  3. API call with token to Pardot endpoint including email address (from step 1), returns an error.

The token is requested as such with relevant client_id, client_secret
https://clients--uat.sandbox.my.salesforce.com/services/oauth2/token

This returns valid token,

{"access_token":"XXXX",
"signature":"XXXX",
"scope":"pardot_api",
"instance_url":"https://clients--uat.sandbox.my.salesforce.com",
"id":"https://test.salesforce.com/id/XXXX",
"token_type":"Bearer",
"issued_at":"XXXX"}

Using the token on the following endpoint, https://pi.demo.pardot.com/api/prospect/version/4/do/read/email/[email protected]?format=json

The Pardot-Business-Unit-Id also checks out as if I change this it will complain. Payload returns with same error no matter what email address I use,

{
    "@attributes": {
        "stat": "fail",
        "version": 1,
        "err_code": 4
    },
    "err": "Invalid prospect email address"
}

Is there an issue with my flow, am I using the wrong endpoint? Could it be possible that there are no prospect email addresses in the account as it is a sandbox account? Any assistance with this would be very much appreciated.

1
  • Your code appears to be correct, so no prospect email addresses in the account as it is a sandbox account is certainly possible. Should be easy to verify, via API or UI. Another solution for this entire flow: 1) Pardot -> Core (Sales/Service Cloud) sync 2) Core -> Marketing Cloud via MC Connect. Both of these steps are out of the box, saving you from making callouts and potentially avoiding the need to script altogether.
    – identigral
    Commented Dec 28, 2023 at 17:06

2 Answers 2

0

You will need to make sure that the Prospect with that email address exists in the Sandbox Pardot Business Unit (when Pardot Sandboxes are created, they are 100% empty, no records or email templates or anything comes over....it's a literal brand new instance).

Next, as you are using V4 of the API, the email address is part of the URL Path, and needs to be URL encoded correctly. Be extra careful for people who are using email aliases (such as [email protected]) as URL encoding may/may not properly encode the + character.

Also, in the sad situation that you have Multiple Prospects with the Same Email, the Read API will pick a Prospect record. This may/may not be good for your situation.

An alternative approach would be to use the v5 Prospect Query API. Because the email is within the JSON payload, you don't have to worry about encoding. Also, this API will return all Prospects matching that email so you have a bit more control over processing the results.

0

The endpoint should be

https://pi.demo.pardot.com/api/prospect/version/4/do/query?format=json&[email protected]

HTTP Method is GET

Headers: Authorization : Bearer , Pardot-Business-Unit-Id : , Content-Type : application/x-www-form-urlencoded

No body required

Succesful return looks like this

{
"@attributes": {
    "stat": "ok",
    "version": 1
},
"result": {
    "total_results": 1,
    "prospect": [
        {
            "id": xxxxx,
            "campaign_id": xxxx,
            "salutation": null,
            "first_name": "xxxx",
            "last_name": "xxxx",
            "email": "[email protected]",
            "password": xxx,
            "company": xxx,
            "website": xxx,
            "job_title": null,
            "department": null,
            "country": null,
            "address_one": null,
            "address_two": null,
            "city": null,
            "state": null,
            "territory": null,
            "zip": null,
            "phone": null,
            "fax": null,
            "source": null,
            "annual_revenue": null,
            "employees": null,
            "industry": null,
            "years_in_business": null,
            "comments": null,
            "notes": null,
            "score": 0,
            "grade": null,
            "last_activity_at": null,
            "recent_interaction": "Never active.",
            "crm_lead_fid": null,
            "crm_contact_fid": null,
            "crm_owner_fid": null,
            "crm_account_fid": null,
            "salesforce_fid": null,
            "crm_last_sync": null,
            "crm_url": null,
            "is_do_not_email": null,
            "is_do_not_call": null,
            "opted_out": null,
            "is_reviewed": null,
            "is_starred": null,
            "created_at": "2024-02-20 16:02:46",
            "updated_at": "2024-02-20 16:02:46",
            "campaign": {
                "id": xxx,
                "name": "xxx"
            }
        }
    ]
}

}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .