Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to Send email using Email REST API

sunmalar
Tera Contributor

Hi Guys,

I tried to Send an email from EMAIL REST API. I got the below error message. Here is my Request format

Accept:application/json
Content-Type: application/json


{"to":"malaravan@example.com","cc":"phil.hendrie@example.com","subject":"Testing for rest email ","text":"Testing for restemail","table_name":"incident","table_record_id":"61ee027b0f305380ac4c4d9ce1050e6a","bcc":"user5@example.com"}

The Error which i received below.

- 500 Internal Server Error

 

{
  "error": {
    "detail": "Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token\n at [Source: com.glide.size_aware.SizeAwareServletInputStream@74acfe; 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@74acfe; line: 1, column: 2] (through reference chain: com.glide.email.service.Email[\"to\"])"
  },
  "status": "failure"
}

Please let me know what is missing here.

 

Thanks,

 

 

 

 

4 REPLIES 4

Bhawana Upreti
Tera Guru

Hi,

I hope given thread might help you.

Thanks.

scwillson
Mega Guru

Did you ever figure this out? the documentation linked previously doesn't seem to help. I've had the same error message, and can't figure out why.

Hi,

Hopefully, this is the blog which you are looking for.

https://developer.servicenow.com/blog.do?p=/post/whats-new-for-developers-in-istanbul---integrations-apis-authentication/

Regards,

Aakash Shah

 

you should construct your rest message properly. Below  rest body works well for me.

 

{

 "to": [

 "josh.nee@servicenow.com",

"dave.slusherwt@servicenow.com"

],

 "subject": "Test from the new Istanbul Email API!",

 "text": "This is pretty cool stuff",

 "table_name": "incident",

 "table_record_id": "d71f7935c0a8016700802b64c67c11c6"

}

 

Thanks,

sun_malar