In this session the team continues building the SSJS coding in the Marketing Cloud to make the Rest API call to send the subscriber through the Wait Until Event in Journey builder.
How to write SSJS code to make an API call from a cloud page (continued)
PART IV: REST call to send package of data to Journey Builder
To begin set up the configuration variable which contains the URL, token and the payload of data you are looking to pass:

(1) If you want to confirm access to the token use this syntax to output the token in the cloud page
(2) Set the variable for the configuration starting with the URL, the REST URL variable set earlier which was the installed package URL plus the string for the Journey Event variation.
(3) Content type is set to application/json to identify the type of data being passed.
(4) Beader names is standard syntax.
(5) HeaderValues is setting the token that was created in the previous step.
(6) Here we are setting the payload which is based on Marketing Cloud syntax: https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/postEvent.html
(7) These are the variables that you are passing to Journey Builder.
PART V: Rest call to send the payload
Time to make that call to the Marketing Cloud installed package to gain access to the instance and generate a token.

(1) Here’s the REST call. There’s a lot going on in this syntax, for a breakdown of the specifics please refer to the following documentation: https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/ssjs_httpPost.html
For our purposes we’ll use the five variables as explained in Part IV
(URL (#2 above), Content type (#3 above), the payload (#6 above), Headernames (#4 above) and HeaderValues (#5 above).
(2) Don’t forget to end your script with a </script)
That’s it! Check out our next session where we validate this is working end to end.

Leave a reply to Jordan Cancel reply