# Variables In JSON Requests

**URL:** <https://community.openhab.org/t/variables-in-json-requests/18716>\
**Category:** Scripts & Rules\
**Created:** [December 24, 2016, 3:16pm UTC](https://community.openhab.org/t/variables-in-json-requests/18716 "2016-12-24T15:16:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Go3Team](https://community.openhab.org/letter_avatar_proxy/v4/letter/g/a9a28c/32.png) [@Go3Team](https://community.openhab.org/u/Go3Team)\
**Post date:** [December 24, 2016, 3:16pm UTC](https://community.openhab.org/t/variables-in-json-requests/18716/1 "2016-12-24T15:16:18Z")

</div>

I’m trying to add a variable to a JSON request. When trying to add the variable to the request, it doesn’t see it as a variable but as part of the message.

Here’s what I have:

```
rule "Office Temp Test"
when
     Item TempInOffice received command ON
then
     var OffTemp = OfficeTemp.state
     var message = "The temperature in the office is " + OffTemp + "degrees."
     var myData = '{
        "entity_id":"media_player.office_home",
        "message":"The temperature in the office is " + OffTemp + "degrees."
     }'
     logInfo("Office Temp",message)
     loginfo("Office Temp",myData)
     sendHttpPostRequest("http://192.168.2.111:8123/api/services/tts/google_say", "HTTP.CONTENT_TYPE_JSON", myData}')
end

```

The first log entry gives:

```
2016-12-24 10:12:06.247 [INFO] [enhab.model.script.Office Temp] - The temperature in the office is 68.6 degrees.

```

The second gives:

```
2016-12-24 10:13:41.268 [INFO] [enhab.model.script.Office Temp] - {
            "entity_id":"media_player.office_home",
            "message":"The temperature in the office is " + OffTemp + " degrees."
    }

```

How can I get it so that the 2nd is the same as the first so that the request gets passed along correctly?

Thanks
