[SFMC] Make postdata payload in SSJS

알린의 개발노트·2023년 6월 21일
0

예시

  var body = {
    'grant_type':'authorization_code',
    'client_id':'4e5ea385244bf6918aa5d7180dbd0b8b',
    'redirect_uri':'https://mcz90ql1wssr79j1bstmb5qj69h8.pub.sfmc-content.com/tsc2mv1pbjd',
    'code':code
  };
  var payload = toFormEncoded(body);

  function toFormEncoded(obj) {
    var newArr = [];
    if (typeof(obj)=='object') {
      for (var i in obj) {
        var encodedKey   = encodeURIComponent(i);
        var encodedValue = encodeURIComponent(obj[i]);
        newArr.push(encodedKey + "=" + encodedValue);
      }
      return newArr.join("&");
    }
  }
profile
안녕하세요!

0개의 댓글