# Error when creating email action with data attachment

**URL:** <https://discuss.elastic.co/t/error-when-creating-email-action-with-data-attachment/48676>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [April 28, 2016, 1:09pm UTC](https://discuss.elastic.co/t/error-when-creating-email-action-with-data-attachment/48676 "2016-04-28T13:09:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eeivin](https://avatars.discourse-cdn.com/v4/letter/e/90ced4/32.png) [@eeivin](https://discuss.elastic.co/u/eeivin)\
**Post date:** [April 28, 2016, 1:09pm UTC](https://discuss.elastic.co/t/error-when-creating-email-action-with-data-attachment/48676/1 "2016-04-28T13:09:37Z")

</div>

I have configured the following action for a watcher

```
                            "actions" : {
                              "watcher_email" : {
                                "email": {
                                  "account": "outlook_account",
                                  "to": "'<testUser@domain.com>'",
                                  "subject" : "Watcher Fatal Alert: {{ctx.payload.hits.total}} log entries --- severity: Fatal",
                                  "body" : "Watcher \"{{ctx.watch_id}}\" Encountered {{ctx.payload.hits.total}} log entries, see attached data",
                                  "attachments" : {
                                    "incidentData.json" : {
                                      "data" : {
                                        "format" : "json"
                                      }
                                    }
                                  },
                                  "priority" : "high"
                                }
                              }
                            }

```

and am getting the following error

## { "error": { "root\_cause": [1] 0: { "type": "parse\_exception" "reason": "could not parse [email] action [_inlined_/watcher\_email]. unexpected token [START\_OBJECT]" }-

"type": "parse\_exception"  
"reason": "could not parse [email] action [_inlined_/watcher\_email]. unexpected token [START\_OBJECT]"  
}-  
"status": 400  
}

without the attachment element, the email action parses and executes with no errors

would appreciate your help

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 28, 2016, 2:19pm UTC](https://discuss.elastic.co/t/error-when-creating-email-action-with-data-attachment/48676/2 "2016-04-28T14:19:56Z")

</div>

Hey,

can you provide more information of the version you are running this against? I just tried this watch and it worked flawless on elasticsearch 2.3.1

```auto
PUT /_watcher/watch/test-watch
{
  "trigger": {
    "schedule": {
      "interval": "10h"
    }
  },
  "actions": {
    "watcher_email": {
      "email": {
        "to": "'<testUser@domain.com>'",
        "subject": "Watcher Fatal Alert: {{ctx.payload.hits.total}} log entries --- severity: Fatal",
        "body": "Watcher \"{{ctx.watch_id}}\" Encountered {{ctx.payload.hits.total}} log entries, see attached data",
        "attachments": {
          "incidentData.json": {
            "data": {
              "format": "json"
            }
          }
        },
        "priority": "high"
      }
    }
  }
}

POST /_watcher/watch/test-watch/_execute

```

Also maybe the full watch would help, in case the parsing gets borked somewhere in the code.

--Alex

---

<div class="post-metadata">

**Author:** ![eeivin](https://avatars.discourse-cdn.com/v4/letter/e/90ced4/32.png) [@eeivin](https://discuss.elastic.co/u/eeivin)\
**Post date:** [April 28, 2016, 5:01pm UTC](https://discuss.elastic.co/t/error-when-creating-email-action-with-data-attachment/48676/3 "2016-04-28T17:01:58Z")

</div>

Thank you Alex.

The issue was the version. After upgrading to 2.3.2, I was able to configure the email action with no errors.

I have an additional question...

Is there a way to the have the original query ("input"🙂 to be included in the email attachment?

Regards,  
Eric

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:45pm UTC](https://discuss.elastic.co/t/error-when-creating-email-action-with-data-attachment/48676/4 "2017-07-06T13:45:52Z")

</div>


