Using this I am unable to see the response coming back. Am I missing something? Any other way the same can be achieved? Thanks!", "datePublished": "2020-07-22T18:55:59.000Z", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54S000006AqW3SAK" }, "image": "https://trailblazers.salesforce.com/ncsphoto/AGHmNbGCib7JEKNZsgq6NvWLsBE-raB4_Sg0IF0X49gF5vBJJcrqS8RWF4IeJHl84z86StAhiEFyrj57wJHbFQ%3D%3D", "about": [], "publisher": { "@type": "Organization", "name": "Trailhead", "url": "https://trailhead.salesforce.com", "@id": "https://trailhead.salesforce.com#Organization" }, "author": { "@type": "Person", "name": "Amisha Nayak", "url": "https://trailblazers.salesforce.com/profileView?u=0053A00000EJ72hQAD", "agentInteractionStatistic": { "@type": "InteractionCounter", "interactionType": "https://schema.org/WriteAction", "userInteractionCount": 1 }, "affiliation": { "@type": "Organization", "name": "Pfizer" } }, "interactionStatistic": { "@type": "InteractionCounter", "interactionType": "https://schema.org/LikeAction", "userInteractionCount": 0 }, "comment": [ { "@type": "Comment", "text": "@Amisha Nayak https://trailblazers.salesforce.com/profileView?u=0053A00000EJ72hQAD 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 #SfmcJourney https://trailhead.salesforce.com/trailblazer-community/topics/sfmcjourney", "author": { "@type": "Person", "name": "Milton Muthuraj Thangapandi", "url": "https://trailblazers.salesforce.com/profileView?u=0053000000An6jMAAR" }, "datePublished": "2020-07-25T00:02:01.000Z" } ] } Skip to main content

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 件のコメント
0/9000