# Permitted characters (eg. '@') in Inputs names?

**URL:** <https://community.openenergymonitor.org/t/permitted-characters-eg-in-inputs-names/24959>\
**Category:** Emoncms\
**Created:** [2 December 2023 17:22 UTC](https://community.openenergymonitor.org/t/permitted-characters-eg-in-inputs-names/24959 "2023-12-02T17:22:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnConnett](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/johnconnett/32/26071_2.png) [@JohnConnett](https://community.openenergymonitor.org/u/JohnConnett)\
**Post date:** [2 December 2023 17:22 UTC](https://community.openenergymonitor.org/t/permitted-characters-eg-in-inputs-names/24959/1 "2023-12-02T17:22:56Z")

</div>

I’m in the process of loading historic data from **rayleighconnect**.

As a first step I used the suggestion from [Posting data in the emonCMS user guide](https://docs.openenergymonitor.org/emoncms/postingdata.html) to create the Inputs.

**Rayleigh** identify sensors with identifiers like “e2.freq”,“e2.i3p@1”,“e2.i3p@2”,“e2.i3p@3” so I decided to use “Rayleigh” as the node and keep those identifiers. My first attempt used the identifiers as is but the ‘@’ didn’t appear in emonCMS. My next attempt replaced the ‘@’ with ‘%40’ and used a URL like this:

```auto
http://127.0.0.1/input/post?node=Rayleigh&fulljson={"e2.freq":0,"e2.i3p%401":0,"e2.i3p%402":0,"e2.i3p%403":0}

```

Again, the identifiers appeared in emonCMS minus the ‘@’. Is this the expected behaviour?

It would be nice to use the same identifiers in both systems but isn’t essential. What are the permitted characters in Inputs names?

---

<div class="post-metadata">

**Author:** ![Robert.Wall](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/robert.wall/32/38246_2.png) [@Robert.Wall](https://community.openenergymonitor.org/u/Robert.Wall)\
**Post date:** [2 December 2023 18:57 UTC](https://community.openenergymonitor.org/t/permitted-characters-eg-in-inputs-names/24959/2 "2023-12-02T18:57:00Z")

</div>

It’s a question that’s come up before, and I don’t think I’ve ever seen a definitive list. As far as I’m aware, nothing outside the plain set of alpha-numerical characters is guaranteed to be acceptable.

If you search for “emonCMS characters”, there are a few historic comments/discussions, only one directly related as I can see - but still not all that helpful.

@TrystanLea , @glyn.hudson ?

---

<div class="post-metadata">

**Author:** ![Bill.Thomson](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/bill.thomson/32/1834_2.png) [@Bill.Thomson](https://community.openenergymonitor.org/u/Bill.Thomson)\
**Post date:** [3 December 2023 03:23 UTC](https://community.openenergymonitor.org/t/permitted-characters-eg-in-inputs-names/24959/3 "2023-12-03T03:23:18Z")

</div>

> [@JohnConnett](#):
>
> My next attempt replaced the ‘@’ with ‘%40’ and used a URL like this:

What you’ve run across is called percent-encoding.  
The following characters are denoted as _reserved,_ i.e. they have special meanings.

`!` `#` `$` `&` `'` `(` `)` `*` `+` `,` `/` `:` `;` `=` `?` `@` `[` `]`

_When a character from the reserved set (a “reserved character”) has a special meaning (a “reserved purpose”) in a certain context, and a URI scheme says that it is necessary to use that character for some other purpose, then the character must be percent-encoded._

Ref:

> **[Percent-encoding](https://en.wikipedia.org/wiki/Percent-encoding)**
>
> URL encoding, officially known as percent-encoding, is a method to encode arbitrary data in a uniform resource identifier (URI) using only the US-ASCII characters legal within a URI. Although it is known as URL encoding, it is also used more generally within the main Uniform Resource Identifier (URI) set, which includes both Uniform Resource Locator (URL) and Uniform Resource Name (URN). As such, it is also used in the preparation of data of the application/x-www-form-urlencoded media type, as is...

---

<div class="post-metadata">

**Author:** ![JohnConnett](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/johnconnett/32/26071_2.png) [@JohnConnett](https://community.openenergymonitor.org/u/JohnConnett)\
**Post date:** [3 December 2023 20:47 UTC](https://community.openenergymonitor.org/t/permitted-characters-eg-in-inputs-names/24959/4 "2023-12-03T20:47:52Z")

</div>

Thanks for the replies. I’m not clear which characters would need to be escaped in the _fulljson_ part of the URL.

According to [RFC 8259, The JavaScript Object Notation (JSON) Data Interchange Format](https://datatracker.ietf.org/doc/html/rfc8259):  
_A string begins and ends with quotation marks. All Unicode characters may be placed within the quotation marks, except for the characters that MUST be escaped: quotation mark, reverse solidus, and the control characters (U+0000through U+001F)._

The ‘@’ character isn’t one that MUST be escaped within a JSON string (but it may be represented as “\u0040”).

PHP seems to be happy with ‘@’ in JSON strings:

```auto
pi@emonpi:/tmp $ php --version
PHP 8.1.26 (cli) (built: Nov 24 2023 13:12:14) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.26, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.26, Copyright (c), by Zend Technologies
pi@emonpi:/tmp $ cat hack.php
cat hack.php
<?php
$jsonobj = '{"e2.freq":0,"e2.i3p@1":0}';

var_dump(json_decode($jsonobj,true));
?>
pi@emonpi:/tmp $ php < hack.php
cat hack.php
array(2) {
  ["e2.freq"]=>
  int(0)
  ["e2.i3p@1"]=>
  int(0)
}
pi@emonpi:/tmp $

```

In case the browser was doing something strange to the URL I tried curl but was unable to produce the equivalent of this example:

```auto
http://emonpi.local/input/post?node=mynode&fulljson={"power1":100,"power2":200,"power3":300}&apikey=fc9c9ae50942b35f8a1baa67649e301b

```

The pragmatic solution would be to replace the ‘@’ characters with ‘\_’ characters. According to [RFC 3986, Uniform Resource Identifier (URI): Generic Syntax](https://datatracker.ietf.org/doc/html/rfc3986) both ‘\_’ and ‘.’ are _unreserved characters_.

---

<div class="post-metadata">

**Author:** ![JohnConnett](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/johnconnett/32/26071_2.png) [@JohnConnett](https://community.openenergymonitor.org/u/JohnConnett)\
**Post date:** [7 December 2023 12:16 UTC](https://community.openenergymonitor.org/t/permitted-characters-eg-in-inputs-names/24959/5 "2023-12-07T12:16:16Z")

</div>

> [@JohnConnett](#):
>
> In case the browser was doing something strange to the URL I tried curl but was unable to produce the equivalent of this example:
> 
> `http://emonpi.local/input/post?node=mynode&fulljson={"power1":100,"power2":200,"power3":300}&apikey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx `

Here’s a curl example that works for me:

```auto
curl \
  --data 'node=mynode&fulljson={"power1":100,"power2":200,"power3":300}&apikey=xxxxxxxxxxxxxxxxxxxxxxx' \
  http://emonpi.local/input/post

```

---

<div class="post-metadata">

**Author:** ![borpin](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/borpin/32/193_2.png) [@borpin](https://community.openenergymonitor.org/u/borpin)\
**Post date:** [7 December 2023 20:10 UTC](https://community.openenergymonitor.org/t/permitted-characters-eg-in-inputs-names/24959/6 "2023-12-07T20:10:33Z")

</div>

> [@JohnConnett](#):
>
> apikey=

Be careful not to post your API key - low risk, but better safe than sorry.
