[Solved] Passing variables to Webcore piston from remote URL call

I'm trying to pass (2) variables to a Webcore piston to allow external process to execute the piston. I can run the piston by connecting to the piston's external URL without a problem but receive an "invalid token" error anytime I try to add the variables.

The URL goes something like this: http://192.168.xx.xx/apps/api/6/execute/:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:?access_token=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx?device=device_name&text=text_string

Here's a screen shot of my piston:

I'm ensuring the variables are URL encoded. For example, spaces have been replaced with %20.

If I open the URL without the variables (remove everything from the ? on) it executes fine. As soon as I add the variables I get the "invalid token" error.

Any assistance anyone can offer is much appreciated. I'm attempting to setup a webcore piston that would allow an external program to do text to speech on various Amazon Echo devices that are controlled in Webcore with the Echo Speaks App,

You have 2 ? in the URL...

Per the Webcore example, the 2 '?' are required. See Simple Remote Control Via URL - Example Pistons - webCoRE Community Forum

Syntactically it should be incorrect, but it's been a while since I used webCore that way (back when I was on ST) so my memory may be faulty.

Looks like a discrepancy between Webcore for Smartthings and Webcore for HE. If you examine the URL generated for a similar piston, you notice the syntax is notably different. For example:

HE
https://cloud.hubitat.com/api/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/apps/6/execute/:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:?access_token=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Smartthings
https://graph-na02-useast1.api.smartthings.com/api/token/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/smartapps/installations/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/execute/:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:

Obviously the hosts will be different but the syntax deviates significantly. This looks like some form of versioning issue between the Smartthings and HE versions of Webcore.

This is a bummer because currently Echo Speaks only works with HE.

Have you tried something like

http://192.168.xx.xx/apps/api/6/execute/:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:?access_token=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&device=device_name&text=text_string

Think you might be on to something here. Hold on....

That solved it - thank you! How did you figure that out?

Fell back on my old web dev memories, and remembered that the data being passed uses the ? as the delimeter from the URI; that meant that everything else you wanted to pass had to go as a named array/map - in a URL those items are delimited by the &

Appreciate the assistance @thebearmay

1 Like

No problem, I got a lot of help from the community up to this point, just paying a little bit of it forward. Holler if you need anything else.