You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

401 Authorization Required when using /interop/rest/v2/mails/send

Using groovy to send email in business rule:

HttpResponse<String> jsonResponse = operation.application.getConnection("SendMail").post('/interop/rest/v2/mails/send').header("Content-Type", "application/json").body(payload).asString();

When I use this I get the 401 error

When I use this, I do not.

HttpResponse<String> emailResponse = operation.application.getConnection("SendMail")
.post("/interop/rest/v2/mails/send")
.header("Authorization", "Basic " + encodedAuth)
.header("Content-Type", "application/json")
.body(payload)
.asString();

Why is this happening? I would prefer to use the credentials in the SendMail connection instead of hard coding in the script which is what this is doing:

.header("Authorization", "Basic " + encodedAuth)

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!