The CreatorCon Call for Content is officially open! Get started here.

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

Mike Patel
Tera Sage

I think endpoint need to be http://devxxxx.service-now.com/api/now/v1/email

Gareth Jones
Kilo Contributor

Tried that - it didn't help

Chuck Tomasi
Tera Patron

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

Gareth Jones
Kilo Contributor

Well - at least now I'm seeing an error message.  Doesn't help alot - but now I have an error message to paste.

find_real_file.png

find_real_file.png
find_real_file.png 
"error": { "detail": "Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token\n at [Source: com.glide.size_aware.SizeAwareServletInputStream@1c4a827; line: 1, column: 2] (through reference chain: com.glide.email.service.Email[\"to\"]) Check logs for error trace or enable glide.rest.debug property to verify REST request processing", "message": "org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token\n at [Source: com.glide.size_aware.SizeAwareServletInputStream@1c4a827; line: 1, column: 2] (through reference chain: com.glide.email.service.Email[\"to\"])" }, "status": "failure" }