0

I've got the following call successfully done in POSTMAN using the form-data: Postman payload request

I am trying to replicate this to an SSJS script but I am having an error : BAD REQUEST,

<script runat=server>
Platform.Load("core", "1.1.1");

var apiKey = '34b7dffb-ace3-46e2-a95b...'
var url = 'https://acwebtest.cruisetraka.com/guestdocument/'

var payload = {
            "ClientId":'133786...',
            "ResId":'20354...',
            "CruiseCode":'AA210...'
        };
    
  var req = new Script.Util.HttpRequest(url);
  req.emptyContentHandling = 0;
  req.retries = 2;
  req.continueOnError = true;
  req.contentType = 'multipart/form-data'
  req.setHeader('api-key', apiKey);
  req.method = 'POST';
  req.postData = Stringify(payload);

  var resp = req.send();
  Platform.Response.Write("</br> response: " + String(resp.content));
  var resultJSON = Platform.Function.ParseJSON(String(resp.content));
  Platform.Response.Write("</br> resultJSON: " + resultJSON);

</script>
7

Your Answer

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

Browse other questions tagged or ask your own question.