BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
geroldpw
Calcite | Level 5

When trying to send email through the VIYA REST api from a shell script I get the following message:

 

{"version":2,"httpStatusCode":400,"message":"The request body was missing or invalid.",
"details":["path: /mail/messages","correlator: 70862b93-1626-4763-ad6d-b7d5d6e1032e"]}

This  is how I issue the request:

 

curl -s -k -X POST "$base_url/mail/messages" \
     -H "Authorization: Bearer $IDTOKEN" \
     -H 'Content-Type: application/vnd.sas.mail+json' \
     -d '{
       "to":"me@email.adres",
       "subject":"testmail door Gerold van viya LTEST",
       "message":"Deze mail wordt verstuurd met de VIYA REST API"
     }'

I can't find documentation on the data part of the request. Documetation only mentions to have the three fields. I tried making the "message" field a list but that doesn't work either.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
gwootton
SAS Super FREQ
The format for the data would be (you could also use "textMessage" instead of "htmlMessage" for a message in plain text):
{
"to": [
{
"address": "user@example.com",
"personal": "Example User"
}
],
"from": {
"address": "from@example.com"
},
"subject": "Subject goes here",
"htmlMessage": "<html><b>Note:</b>This is an HTML email.</html>"
}
--
Greg Wootton | Principal Systems Technical Support Engineer

View solution in original post

15 REPLIES 15
gwootton
SAS Super FREQ
The format for the data would be (you could also use "textMessage" instead of "htmlMessage" for a message in plain text):
{
"to": [
{
"address": "user@example.com",
"personal": "Example User"
}
],
"from": {
"address": "from@example.com"
},
"subject": "Subject goes here",
"htmlMessage": "<html><b>Note:</b>This is an HTML email.</html>"
}
--
Greg Wootton | Principal Systems Technical Support Engineer
geroldpw
Calcite | Level 5
Thanks a lot! I have it working. By the way, .. 'from' address can't be overruled. It is immutably configured in VIYA.
Is all this documented anywhere?

Thanks again,
Gérold
gwootton
SAS Super FREQ
The mail service API is not currently documented.
--
Greg Wootton | Principal Systems Technical Support Engineer
paterd2
Obsidian | Level 7

Mr. Gwooton,

how can i use this with starttls, the example is not working with starttls eventhough we have mail.smtp.starttls.enable : true in configuration.

 

Example error output :

 

{"version":2,"httpStatusCode":400,"errorCode":11104,"message":"Couldn't connect to host, port: OURSMTPSERVER, 25; timeout -1","details":["Caused by gomail: could not send email 1: 530 #5.7.0 Must issue a STARTTLS command first","path: /mail/messages","correlator: f965315d-08e9-4af1-bf19-e4227f7fda74"]}sh-4.4$

gwootton
SAS Super FREQ
How did you set mail.smtp.starttls.enable? In sas.mail configuration under customProperties? It sounds like this is not being honored.
--
Greg Wootton | Principal Systems Technical Support Engineer
paterd2
Obsidian | Level 7

Yes we did this.

gwootton
SAS Super FREQ
Have you tried using the secure TLS ports (587 or 465) instead?
--
Greg Wootton | Principal Systems Technical Support Engineer
paterd2
Obsidian | Level 7
We do not have these ports open, but if I lauch it with curl directly it works fine with --ssl-reqd on port 25.
even if I mail from studio, with starttls it works fine.
gwootton
SAS Super FREQ
You should engage SAS Technical Support to have them take a look at your configuration.
--
Greg Wootton | Principal Systems Technical Support Engineer
paterd2
Obsidian | Level 7

Greg,

this is what I sended to support today.

Dear Support,

 

eureka !

I found a workaround by accident .

 

I saw that we have DEBUG=true as optional parameter.

 
 
I removed it, and the sas-mail pod was not able to start.

I added DEBUG=true and the pod started again.

Then today I had a brainwave.

I changed DEBUG=true in ...... mail.smtp.starttls.enable=true.

IT WORKS !!!!

paterd2
Obsidian | Level 7
Excuse me :
Not optional but properties.

properties:
mail.smtp.starttls.enable=true
(Deprecated) Optional properties set on the remote mail server.
gwootton
SAS Super FREQ
Great news! I'm pleased to hear you got it working.

So you modified the mail.debug=false set by default in the deprecated properties field (that had been changed to true in your case) to mail.smtp.starttls.enable=true and it picked it up?
--
Greg Wootton | Principal Systems Technical Support Engineer
paterd2
Obsidian | Level 7

Greg, exactly !

Regards. 

 

Dik

Sathyaseelan_C
Fluorite | Level 6

Any idea how to send with attachments, using this same method