JSON Response Not Working


#1

1) Give a description of the problem
Two queries to the same site produce different results.

2) What is the expected behavior?
Return Holiday info on respective Web request

3) What is happening/not happening?
The Workday query is correct and returns a value. Although testing the exact URL manually in a browser works correctly, in WebCoRE, it returns a Null

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
0f3ad38d-3925-4a09-8b33-f51e517e6396 9:36:29 AM: trace ║║ Executed virtual command setVariable (3ms)

[0f3ad38d-3925-4a09-8b33-f51e517e6396](https://graph-na02-useast1.api.smartthings.com/ide/logs#0f3ad38d-3925-4a09-8b33-f51e517e6396) 9:36:29 AM: trace ║║ Executed virtual command httpRequest (527ms)

[0f3ad38d-3925-4a09-8b33-f51e517e6396](https://graph-na02-useast1.api.smartthings.com/ide/logs#0f3ad38d-3925-4a09-8b33-f51e517e6396) 9:36:29 AM: trace ║╔ Execution stage complete. (1217ms)

[0f3ad38d-3925-4a09-8b33-f51e517e6396](https://graph-na02-useast1.api.smartthings.com/ide/logs#0f3ad38d-3925-4a09-8b33-f51e517e6396) 9:36:29 AM: debug ║║ Calculating (string) https://kayaposoft.com/enrico/json/v2.0/?action=isWorkDay&date= + (string) 20-08-2018 >> (string) https://kayaposoft.com/enrico/json/v2.0/?action=isWorkDay&date=20-08-2018

[0f3ad38d-3925-4a09-8b33-f51e517e6396](https://graph-na02-useast1.api.smartthings.com/ide/logs#0f3ad38d-3925-4a09-8b33-f51e517e6396) 9:36:29 AM: debug ║║ Calculating (string) https://kayaposoft.com/enrico/json/v2.0/?action=isWorkDay&date=20-08-2018&country=usa& + (string) region=ny >> (string) https://kayaposoft.com/enrico/json/v2.0/?action=isWorkDay&date=20-08-2018&country=usa&region=ny

[0f3ad38d-3925-4a09-8b33-f51e517e6396](https://graph-na02-useast1.api.smartthings.com/ide/logs#0f3ad38d-3925-4a09-8b33-f51e517e6396) 9:36:29 AM: debug ║║ Sending external web request to: kayaposoft.com/enrico/json/v2.0/?action=isWorkDay&date=20-08-2018&country=usa&region=ny

[0f3ad38d-3925-4a09-8b33-f51e517e6396](https://graph-na02-useast1.api.smartthings.com/ide/logs#0f3ad38d-3925-4a09-8b33-f51e517e6396) 9:36:29 AM: info ╔ Event processed successfully (1339ms)

[0f3ad38d-3925-4a09-8b33-f51e517e6396](https://graph-na02-useast1.api.smartthings.com/ide/logs#0f3ad38d-3925-4a09-8b33-f51e517e6396) 9:36:28 AM: debug ║║ Sending external web request to: kayaposoft.com/enrico/json/v2.0/?action=getHolidaysForDateRange&fromDate=25-12-2018&toDate=25-12-2018&country=usa&region=ny&holidayType=public_holiday

[0f3ad38d-3925-4a09-8b33-f51e517e6396](https://graph-na02-useast1.api.smartthings.com/ide/logs#0f3ad38d-3925-4a09-8b33-f51e517e6396) 9:36:29 AM: debug ║║ Calculating (string) https://kayaposoft.com/enrico/json/v2.0/?action=isWorkDay&date=20-08-2018 + (string) &country=usa& >> (string) https://kayaposoft.com/enrico/json/v2.0/?action=isWorkDay&date=20-08-2018&country=usa&

[0f3ad38d-3925-4a09-8b33-f51e517e6396](https://graph-na02-useast1.api.smartthings.com/ide/logs#0f3ad38d-3925-4a09-8b33-f51e517e6396) 9:36:29 AM: trace ║║ Executed virtual command httpRequest (620ms)

[0f3ad38d-3925-4a09-8b33-f51e517e6396](https://graph-na02-useast1.api.smartthings.com/ide/logs#0f3ad38d-3925-4a09-8b33-f51e517e6396) 9:36:29 AM: trace ║║ Executed virtual command setVariable (3ms)

[0f3ad38d-3925-4a09-8b33-f51e517e6396](https://graph-na02-useast1.api.smartthings.com/ide/logs#0f3ad38d-3925-4a09-8b33-f51e517e6396) 9:36:28 AM: debug ║║ Calculating (string) https://kayaposoft.com/enrico/json/v2.0/?action=getHolidaysForDateRange&fromDate=25-12-2018&toDate=25-12-2018 + (string) &country=usa& >> (string) https://kayaposoft.com/enrico/json/v2.0/?action=getHolidaysForDateRange&fromDate=25-12-2018&toDate=25-12-2018&country=usa&

[0f3ad38d-3925-4a09-8b33-f51e517e6396](https://graph-na02-useast1.api.smartthings.com/ide/logs#0f3ad38d-3925-4a09-8b33-f51e517e6396) 9:36:28 AM: debug ║║ Calculating (string) https://kayaposoft.com/enrico/json/v2.0/?action=getHolidaysForDateRange&fromDate=25-12-2018&toDate=25-12-2018&country=usa& + (string) region=ny&holidayType=public_holiday >> (string) https://kayaposoft.com/enrico/json/v2.0/?action=getHolidaysForDateRange&fromDate=25-12-2018&toDate=25-12-2018&country=usa&region=ny&holidayType=public_holiday

[0f3ad38d-3925-4a09-8b33-f51e517e6396](https://graph-na02-useast1.api.smartthings.com/ide/logs#0f3ad38d-3925-4a09-8b33-f51e517e6396) 9:36:28 AM: trace ║╚ Execution stage started

[0f3ad38d-3925-4a09-8b33-f51e517e6396](https://graph-na02-useast1.api.smartthings.com/ide/logs#0f3ad38d-3925-4a09-8b33-f51e517e6396) 9:36:28 AM: trace ║ Runtime (40844 bytes) successfully initialized in 58ms (v0.3.107.20180806) (117ms)

[0f3ad38d-3925-4a09-8b33-f51e517e6396](https://graph-na02-useast1.api.smartthings.com/ide/logs#0f3ad38d-3925-4a09-8b33-f51e517e6396) 9:36:28 AM: debug ║║ Cancelling statement #1's schedules...

[0f3ad38d-3925-4a09-8b33-f51e517e6396](https://graph-na02-useast1.api.smartthings.com/ide/logs#0f3ad38d-3925-4a09-8b33-f51e517e6396) 9:36:28 AM: debug ║ RunTime Analysis CS > 21ms > PS > 58ms > PE > 38ms > CE

[0f3ad38d-3925-4a09-8b33-f51e517e6396](https://graph-na02-useast1.api.smartthings.com/ide/logs#0f3ad38d-3925-4a09-8b33-f51e517e6396) 9:36:28 AM: info ╚ Received event [Home].execute = 74.102.90.198 with a delay of 55ms

Thanks


Feature Request: Piston $return variable
#2

I tried doing the web request and got the proper response… I did modify your piston a bit though.

image


#3

That modification worked? Because it also removed my formatting of the &region value, resulting in “&reg” being converted to the HTML5 character entity reference of the ”®” symbol, as you can see in your upload. That worked for you despite this?


#4

It looks like a display bug. Tagging @ipaterson to see if it is. The URL is still correct in the editor if I open it.


#5

Would you mind please saving a screenshot with a backup code so I can load what you did? Adding the log to message didn’t make a difference and my workday query loads as expected without. Thanks.


#6

I split the URL at the ‘region’ part…

image


#7

Thanks but I’m still getting the same non-result. I had to still enter the url’s themselves so I’m not sure if that’s the issue or not. You’re getting the full Christmas Day holiday value for the non-Boolean variable?


#8

Sorry, in the first piston I posted, I was just logging the $response. This time, I modified it to save the $response to variable and this is what I have as far as value after executing the piston.


#9

Yes, a display bug. There have been similar reports in the past, it’s caused by a pattern used throughout the app that could be very time consuming to fix. The fix is replacing & with & in any user input that is displayed as HTML, in a way that does not interfere with any of the webCoRE content. URLs are particularly prone to this display glitch due to the & character.


Preserving URL with an Escape character?
#10

Yes that’s exactly what my initial URL posted in the first message did. It displays without the “amp;” in the same way the ® replaces the “&reg.” I’ve worked that bit out … but I’m still unable to return anything but a null value for that query. The other (using the same formatting on the region) works as expected.


#11

Yet somehow this worked. It makes no sense to me at all why but I’ve learned to stop concerning myself with the why when something finally works.
Thanks for your help guys.