How do I pass a string (with spaces) to an internet cloud endpoint (cloud.hubitat.com)?

Basically, I want the hub to receive a string from the internet, store it into a variable, and then use it like speak it to a device. I've seen posts referencing /setGlobalVariable=:, but I get an error if I stick it into the cloud endpoint url:

eg:
https://cloud.hubitat.com/api/<long-string>/apps/<rule-id>/trigger/setGlobalVariable=testvar:value?access_token=<token-string>

When I randomly added my string after the /trigger/ like this:
https://cloud.hubitat.com/api/<long-string>/apps/<rule-id>/trigger**/any text I want goes here**?access_token=<token-string>
My browser would replace the spaces with %20 and the string is stored in the rule's local variable named %value% (weird). The % in the string is also causing problems since the rule tried to interpret variable values and so there are many null20 in the string.

Is there an easier and more reliable way to pass in a string? I'm also open to other ways like sending the hub an sms or email message.

There should be a URLencode and URLdecode option.

I only see URL Encode option.

And this is output from the cloud endpoint:
2022-12-08 07_32_55-https___cloud.hubitat.com_api_e558c130-3f00-45ca-a6fd-2376bb98932f_apps_342_trig

And the value is stored correctly as a local variable:
2022-12-08 07_39_06-echo cloud announce

But to manually replace the encoded characters like "%20" -> " ", I have to first store %value% into a normal local variable. But that results in the % signs being interpreted and I lose some of the content.

  • original: This is a test of string input
  • %value%: This%20is%20a%20test%20of%20string%20input
  • copied to another var: Thisnull20anull20ofnull20input


The receiving endpoint will do the URL decode automatically...

The hubitat is the receiving endpoint.
Internet browser/app -> hubitat cloud endpoint -> my hubitat
In case there is any confusion, the cloud endpoint is created by setting a rule trigger to Cloud End Point.

Excerpt from Rule Machine API

Set Hub Variable

A Hub Variable can be set by an endpoint trigger. The format for the parameter is this:

/setHubVariable=varName:varString

The varString portion is assumed to be URL encoded, and is URL decoded before being stored into the varName Hub Variable.

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.