HTTP GET action questions

Rule machine. HTTP GET. Not working. Trying to edit the "URL to send Request to" for some reason it doubles the HTTP URL. Deleting and starting over does not work.

Can you post screenshots indicating the issue with using http get in RM?

I cannot get HTTP GET command to work, but it works in any browser. After reading through the forums, they said it might be the quotes causing the problem and to use a confirmed URL. So, that is what I did, and now Hubitat shows the URL with parentheses around it again. Not sure why GET does not work and why there are parentheses around the URL when I change the quotes to %20

Because GET is not working either way and there is an unexplained difference I wanted to confirm this is not a Bug and chasing a wild goose.

Thanks.

Duplicates
https://admin:password@192.168.1.2:8000/api/createEvent?eventType"GenericEvent"

Does not duplicate
https://admin:password@192.168.1.2:8000/api/createEvent?eventType"GenericEvent"

I'm using HTTP GET since years without any problems.

IMHO in your case Basic Authentication via credentials in URL (...uid:pwd@...) could be raise your problem.

From what little I know about variable references in Rule Machine, your use of the % in this context will be problematic. Namely, RM is interpreting %22GenericEvent% as the name of a local var (called 22GenericEvent), which (a) does not exist, and (b) therefore returns the value null.

Seems like something to avoid.

LOL, crazy. I thought I made a mistake in my original post. So I went to correct it and even the community board corrected the %20 to quotes. Too funny. See picture.

Anyway. How can I fix this and why the parentheses? Maybe use a variable for the entire URL? I will try that but what is normal practice?

The easiest way is to use variable.
Here is a recent discussion on the topic:

Since your string has variable replacement, the string in parentheses is showing what the actual request will be with variables expanded.

Got it on the parentheses, thanks. For others, see the picture for an explanation.

Totally lost on the reference to the new action "URL encode into a string." No matter what I do, with quotes, without quotes (using %20), or putting both ways in a string variable with and without credentials, it does nothing. The log always shows it correctly, but it does nothing. Only works in a browser.

In URLs, some characters, like quotes, need to be encoded using the standard http "% encoding". If you put quotes into a browser location bar, most modern browsers will automatically convert it to the proper encoded form. You can see this if you monitor the traffic with developer tools (or similar).

For your case, I think what you want to do is to set the variable with the encoded string and then use that for the GET location. If you are manually entering the variable, use %22 instead of quotes.

1 Like