Trying to use sevice now Email API to send an email

Gareth Jones
Kilo Contributor

I'm trying to use the Email API to send and email.  I've fired up a Personal Developer Instance, added email_api_send role to the admin account, turned on email send/receive in email properties, and am sending the following...

curl "http://devxxxx.service-now.com/api/now/email" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{
\"to\": [
\"gareth <gjones@ca.ibm.com>\"
],
\"subject\": \"Hello There\",
\"text\": \"Test Message\",
\"html\": \"<b>Test Message</b>\",
\"table_name\": \"incident\",
\"table_record_id\": \"xxxxxx\",
\"headers\": {
\"X-Custom\": \"header\"
}
}" \
--user 'admin':'xxxxx'

Where - obv - the xxx are replaced with valid numbers.

Get nothing back.  Get no emails created. (looked in the email log)

New to this stuff - what am I missing...

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Have you been able to get this working with the REST API Explorer?

View solution in original post

6 REPLIES 6

Gareth Jones
Kilo Contributor

Never Mind - sent it as raw - as per the documentation - and it worked...now - to figure out what is different

 

Gareth Jones
Kilo Contributor

Thanks for the help with this!

 

Turns out - difference between https and http - working curl script...

 

curl "https://devxxxx.service-now.com/api/now/v1/email" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{
              \"to\": [
                  \"gareth <gjones@ca.ibm.com>\"
              ],
              \"subject\": \"Hello There\",
              \"text\": \"Test Message\",
              \"html\": \"<b>Test Message</b>\",
              \"headers\": {
                  \"X-Custom\": \"header\"
              }
          }" \
--user 'admin':'admin'

with xxx replaced and password added.

thanks!