# Logstash : Invalid FieldReference: \`${http.headers\[\\"User-Agent\\"\]}\`"

**URL:** https://discuss.elastic.co/t/logstash-invalid-fieldreference-http-headers-user-agent/370403
**Category:** Logstash
**Created:** [November 12, 2024, 1:59pm UTC](https://discuss.elastic.co/t/logstash-invalid-fieldreference-http-headers-user-agent/370403 "2024-11-12T13:59:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rehanpfmr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rehanpfmr/32/139127_2.png) [@rehanpfmr](https://discuss.elastic.co/u/rehanpfmr)
#### Post date: [November 12, 2024, 1:59pm UTC](https://discuss.elastic.co/t/logstash-invalid-fieldreference-http-headers-user-agent/370403/1 "2024-11-12T13:59:59Z")

</div>

I'm having difficulty in parsing json object, the json field name is having special characters in it and logstash is showing error _as JSON parse error, original data now in message field._

ERROR message: JSON parse error, original data now in message field {:message=\>"Invalid FieldReference: `${http.headers[\"User-Agent\"]}`", :exception=\>LogStash::Json::ParserError

RAW message field that it trying to parse:

"customMsgAtts": {  
"${http.headers["User-Agent"]}": "XXXX/X.X.X\_XXX",  
},

I tried to rename the field as below, but that doesn't work:

mutate {rename =\> { "[customMsgAtts][${http.headers["User-Agent"]}]" =\> "http\_headers\_User\_Agent" }}

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [November 12, 2024, 3:23pm UTC](https://discuss.elastic.co/t/logstash-invalid-fieldreference-http-headers-user-agent/370403/2 "2024-11-12T15:23:21Z")

</div>

What exactly is the raw message field? Much to my surprise

```
input { generator { count => 1 lines => ['{ "customMsgAtts": { "${http.headers[\"User-Agent\"]}": "XXXX/X.X.X_XXX" } }' ] } }
output { stdout { codec => rubydebug { metadata => false } } }
filter { json { source => "message" } }

```

works just fine and produces

```
"customMsgAtts" => {
    "${http.headers[\"User-Agent\"]}" => "XXXX/X.X.X_XXX"
},
      "message" => "{ \"customMsgAtts\": { \"${http.headers[\\\"User-Agent\\\"]}\": \"XXXX/X.X.X_XXX\" } }",

```
