0

Here's my code below. The error happens at the first HTTP.Post call. The error message is simply:

ExactTarget.OMM.FunctionExecutionException:  An error occurred when attempting to evaluate a HTTPPost function call.  See inner exception for details.
Source:  OMMCommon

This had previously worked for me before. I double checked the syntax on the HTTP.Post call, everything seems fine. Is there anything I'm just missing?

<script type="text/javascript" runat="server">
Platform.Load("core", "1");
var dataRows = Platform.Function.LookupRows('Paused_Automations_SMS_Notification','ReturnAll','1');
    if(dataRows && dataRows.length > 0) {
       var tokenURL = 'https://hhhhhhhhhh.auth.marketingcloudapis.com/v2/token';
       var payload = {
           "clientId": "hhhhhhhhh",
           "clientSecret": "hhhhhhhhhhh"
       };
       var contentType = 'application/json';
       var resultToken = HTTP.Post(tokenURL, contentType, Stringify(payload), headerNames, headerValues);
       var accessToken = Platform.Function.ParseJSON(resultToken["Response"][0]).accessToken;

       var headerNames = ["Authorization"];
       var headerValues = ["Bearer " + accessToken];

       for (var i = 0; i < dataRows.length; i++) {
           var smsurl = 'https://hhhhhhhhhh.rest.marketingcloudapis.com/sms/v1/queueMO';
            var smsPayload = {
                "mobileNumbers" : [
                dataRows[i].MobileNumber
            ],
                "shortCode" : "80565",
                "messageText" : "MIKETESTERLE" + " " + dataRows[i].AutomationName
            };
            var smsresult = HTTP.Post(smsurl, contentType, Stringify(smsPayload), headerNames, headerValues);
        }
    }
</script>
1
1

It seems that you are trying to use a v2 auth endpoint with v1 client credentials.

In your tokenURL, try replacing: /v2/token with: /v1/requestToken

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.