Hi,
I have an SSJS Script which will fetch Campaign details from Braze and send it across to Microsoft Team. I have been facing few errors in validating the script. Let me know if any can help with the same.
Hi,
I have an SSJS Script which will fetch Campaign details from Braze and send it across to Microsoft Team. I have been facing few errors in validating the script. Let me know if any can help with the same.
Hi All,
I've been trying to use WSProxy to dynamically update publication lists in multiple child BU's using an SSJS activity in an Automation.
I've noticed very strange behaviour where the script executes successfully and I'm getting a successful response from the WSProxy API, however the subscriber isn't getting updated in the corresponding Publication List.
In my real automation, I populate a DE with the details of the subscribers who need to be resubscribed and use the DE data as my source for the script activity
Sample code below:
<script runat="server">
Platform.Load("core", "1.1");
var api = new Script.Util.WSProxy();
var buId = nnnnnn;
var listId = llllll;
api.setClientId({"ID": buId});
var options = {
SaveOptions: [{
PropertyName: "*",
SaveAction: "UpdateAdd"
}]
};
try {
var sub = {
SubscriberKey: "SubKey1",
EmailAddress: "xxx@xxx.com.au",
Lists: [{
ID: listId,
Status: "Active"
}]
};
var resp = api.createItem("Subscriber", sub, options);
Write(Stringify(resp));
} catch(e) {
Write(Stringify(e));
}
api.resetClientIds();
</script>
Has anyone else noticed this behaviour in their environment?
I will be raising a case with SF as well, but hopefully someone here has a solution/workaround.
#MCExperts #MCDeveloper #wsproxy, #ssjs, #SSJS Script , #Marketing Cloud Publication Lists
To make the mid dynamic here is the code :
Platform.Recipient.GetAttributeValue('memberid'); //SSJS
What you could have tried - copy the SSJS into a code snippet in the shared folder, call the code snippet in the child BU cloud page or Automation SSSJ script activity.
<script runat="server"> var ampscriptCode = Platform.Function.ContentBlockByID("12345"); </script>
Hi All - I am trying to Integrate SFMC to an External Service via REST API.
Here is the SSJS script that I have:
<script runat=server>
Platform.Load('Core','1.1.1');
var host = 'https://apis-dev.cxawsnprd.?????????.com/LLauthtoken/ui'
user = 'XXXXXXXXXXXXX',
password = "YYYYYYYYYYYYYY";
var token = retrieveToken(host,user,password);
function retrieveToken(host,user,password) {
var url ='https://apis-r-dev.?????????.com/rest/streamingproxy/topics/test';
var payload = {
"records": [
{
"key": "a2V5",
"value": "Y29uZmx1ZW50"
},
{
"value": "a2Fma2E="
}
]
};
var req = new Script.Util.HttpRequest(url);
req.emptyContentHandling = 0;
req.retries = 2;
req.continueOnError = true;
req.contentType = "application/vnd.kafka.json.v2+json"
req.method = "POST";
req.postData = Stringify(payload);
var resp = req.send();
var resultStr = String(resp.content);
var resultJSON = Platform.Function.ParseJSON(String(resp.content));
return resultJSON.token;
}
</script>
Using this I am unable to see the response coming back. Am I missing something? Any other way the same can be achieved?
Thanks!
1) Have you tested your api using PostMan or other tool first?
2) If it works, does the SSJS throw any error? If so, can you share the error?
3) If not, 'Print' the SSJS var at every stage and debug it
#SfmcJourneyHi, I'm creating a cloud page to be used as an endpoint for a thirdparty connection (just like an REST API endpoint) with SSJS (Server Side Javascript). And I would like to know if is it possible to set HTTP Codes. Like if the thirdparty tries to call the endpoint with a invalid access token I would like to response that request with the HTTP Code 401 - Unauthorized or when it is an invalid body data return HTTP Code 400 and so on.
Trying to query a 3rd party API through a post request from a SSJS script. However, I get the following error:
System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond XX.XX.XX.XX:8088 - from System
In postman I can query the API successfully in a reasonable time. However not from SFMC. I can get SFMC to query the 3rd party website on port 80 correctly. So I suspect it may have something to do with the port being 8088. Anyone else seen anything like this before?