We want to invoke MC Campaign Creation API from SSJS. Campaign data to be created in MC we are fetching from external data source. While creating Campaign REST API Payload to invoke MC API from SSJS, we are using String concat() functions to create payload. However we are getting error "Bad Request" while creation of payload using contact().
how to create Payload if we use variable, for values in SSJS ?
Snippet :-
var mypayloadfir = '"description": "' ;
ar mypayloadsec = '","name": "';
var mypayloadth = '","campaignCode": "';
url = 'https://XXX/hub/v1/campaigns';
contentType = 'application/json';
Payload = '{' + mypayloadfir + sfdc_camp_desc + mypayloadsec + sfdc_camp_name +mypayloadth + sfdc_camp_code + '"}';
Write(Payload);
var headerNames = ["Authorization"];
var headerValues = ['Bearer ' + accessToken];
Write(sfdc_camp_name + '<br>');
result = HTTP.Post(url, contentType, payload, headerNames, headerValues);
Write(sfdc_camp_name + '<br>');