0

I have seen a few posts about how this can be done using oauth, but I need to use basic auth and I can't seem to get it to work. Below is an example of the code I'm using.

<script type="javascript" runat="server">

Platform.Load("core", "1.1.5");

var url = 'https://example.com/';
var contentType = 'application/json';
var header = 'auth=("username", "password")';

var payload = '{';
payload += ' "body":"This is a comment"';
payload += '}';

var result = HTTP.Post(url, contentType, payload, header);

</script>
2

You need to base64 encode your username and password like this:

var user = 'foo';
var password = 'bar';
var auth = 'Basic ' + Platform.Function.Base64Encode(user+':'+password);
var header = 'Authorization: ' + auth;
| improve this answer | |

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.