Issues with web GET truncation


#1

1) Give a description of the problem
I believe that my URLs are being truncated - I’m getting api key errors if the api key is at the end of the URL and im getting data errors if the data is at the the end.

The URL source is 192.168.13.237/emoncms/input/post?apikey={apikey}&node={$currentEventDevice}&fulljson={urlEncode(strLeftCurly)}{urlEncode(strDQuote)}{$currentEventAttribute}{urlEncode(strDQuote)}:{round($currentEventValue,2)}{urlEncode(strRightCurly)}

Oddly enough this was working for an externally hosted version of this service, but it uses a shorter hostname and is missing /emoncms/ from the url as well, leading me to believe that truncation is the issue. Alas I’m not a good enough Linux/Apache hacker to see what the URL is from the other servers perspective.

The docco for inputting to EmonCMS is here - https://emoncms.org/Modules/site/api.php

2) What is the expected behaviour?
That the URL generated by the piston was actually submitted, not a truncated version.

3) What is happening/not happening?
The machine receiving the web request isn’t happy with the URL. The Piston logs show a URL that works if I put it in a browser, but the URL actually submitted isn’t the same.

+170ms ║║Sending internal web request to: 192.168.13.237/emoncms/input/post?apikey=43c74826014779bd5257278584e11814&node=Air%20Conditioner&fulljson=%7B%22temperature%22:22%7D

Gets an error from the receiving server:

But chrome works:

4) Post a Green Snapshot of the pistonimage

14/06/2020, 20:54:56 +746ms
+2ms	╔Received event [Air Conditioner].temperature = 22.0 with a delay of 78ms
+102ms	║RunTime Analysis CS > 21ms > PS > 27ms > PE > 54ms > CE
+105ms	║Runtime (41633 bytes) successfully initialized in 27ms (v0.3.110.20191009) (102ms)
+105ms	║╔Execution stage started
+113ms	║║Cancelling statement #16's schedules...
+132ms	║║Calculating (string) 192.168.13.237/emoncms/input/post?apikey= + (string) AAAAAAAAAAAAAAAAAAAAAAAAAAAA >> (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA
+136ms	║║Calculating (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA + (string) &node= >> (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=
+140ms	║║Calculating (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node= + (string) Air Conditioner >> (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air Conditioner
+143ms	║║Calculating (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air Conditioner + (string) &fulljson= >> (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air Conditioner&fulljson=
+147ms	║║Calculating (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air Conditioner&fulljson= + (string) %7B >> (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air Conditioner&fulljson=%7B
+150ms	║║Calculating (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air Conditioner&fulljson=%7B + (string) %22 >> (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air Conditioner&fulljson=%7B%22
+153ms	║║Calculating (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air Conditioner&fulljson=%7B%22 + (string) temperature >> (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air Conditioner&fulljson=%7B%22temperature
+156ms	║║Calculating (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air Conditioner&fulljson=%7B%22temperature + (string) %22 >> (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air Conditioner&fulljson=%7B%22temperature%22
+159ms	║║Calculating (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air Conditioner&fulljson=%7B%22temperature%22 + (string) : >> (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air Conditioner&fulljson=%7B%22temperature%22:
+161ms	║║Calculating (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air Conditioner&fulljson=%7B%22temperature%22: + (string) 22 >> (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air Conditioner&fulljson=%7B%22temperature%22:22
+164ms	║║Calculating (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air Conditioner&fulljson=%7B%22temperature%22:22 + (string) %7D >> (string) 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air Conditioner&fulljson=%7B%22temperature%22:22%7D
+170ms	║║Sending internal web request to: 192.168.13.237/emoncms/input/post?apikey=AAAAAAAAAAAAAAAAAAAAAAAAAAAA&node=Air%20Conditioner&fulljson=%7B%22temperature%22:22%7D
+195ms	║║Executed virtual command httpRequest (27ms)
+196ms	║║Requesting a wake up for Sun, Jun 14 2020 @ 8:55:16 PM AEST (in 20.0s)
+200ms	║╚Execution stage complete. (95ms)
+201ms	║Setting up scheduled job for Sun, Jun 14 2020 @ 8:55:16 PM AEST (in 19.996s)
+209ms	╚Event processed successfully (209ms)
14/06/202

#2

Not sure what is going on but I suggest creating a string variable ‘url’ and assembling your request. Then you can look to be sure your full request string is correct and see if it works doing GET {url}.


#3

It looks to me like the piston thinks you have defined a query string in your ‘Make a web request’ settings and has stuck it on the end of the url.

There is a known bug with the query string settings where if you set variables in ‘Send variables’ and change your mind to ‘Nothing selected’, the variables still get sent as a query string. So take a look in ‘Send variables’ and remove any variables added there.


#4

Not sure why your URL is getting truncated.

Note that your GET request will be automatically URLencoded, thus you can shorten your expression considerably, which may help you find the problem.


#5

Just following up to say I didn’t get a solution to this problem, but I worked around it by posting the variables as form data. The results are here.