1

Is it possible to call an external API call via marketing cloud pages?

Use case: I will be creating a cloud page to capture customer information, as soon as the form is submitted, I want to pass these details to Salesforce CRM via web service API call. We already have built the Salesforce API call.

Thank you for looking into this in advance.

1 Answer 1

2

If I understand you correctly you are not using Marketing Cloud Connect between Salesforce CRM and Salesforce Marketing Cloud and you want to use custom built solution to send MC form data to Salesforce.

Just in case pointing out this would be dead easy if you had the MCC in place, as there are very specific AMPscript functions meant exactly for that.

Anyway, to answer your question - yes, you can do external API calls within Cloud Page to post the data to external systems. You'll be utilizing SSJS for that.

More specifically you'll want Script.Util.HttpRequest for this, with this function you can use any of the following :

GET
DELETE
HEAD
OPTIONS
PATCH
POST
PUT

Example script on using SSJS.

<script runat=server>
Platform.Load("core", "1.1.1");

var accessToken = {{yourToken}};
var url = 'https://www.exacttargetapis.com/asset/v1/content/assets/{{ContentID}}'

var payload = '{{thePayload}}';

var auth = 'Bearer ' + accessToken;

  var req = new Script.Util.HttpRequest(url);
  req.emptyContentHandling = 0;
  req.retries = 2;
  req.continueOnError = true;
  req.contentType = "application/json"
  req.setHeader("Authorization", auth);
  req.method = "PUT"; (any of the methods above)
  req.postData = payload;

  var resp = req.send();
</script>

You must log in to answer this question.

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