Rules and sendHttpPutRequest

Well in short i cant get it to work!
in curl in the commandline it works.
In the Rule script it doesn’t.
In the tail of the log (very handy that screen).
I don’t see any error (i seet he correct prints).

Also if i try to get the result of the execution i can’t show it anywhere:


var result = "";

val headers = newHashMap("Authorization" -> "Bearer oh.api.4LEObyXg4YZtR7fbvKsbiebcXJz1ItVn9E4SLmvlm8SJvzbneItFU4CQBnKTR0PSOYonrfrigTu3kOFzPWvw");

result = sendHttpPutRequest("http://192.168.1.76:8080/rest/thing/http:url:7dc8fc6207/enable", "text/plain", "True", headers, 1000);

logInfo("Auto StartStop Things", result ); 

Just prints an empty line.

has to be:
things

Pohhhhh the fact that i’m blind reading that and the log just stayed silence accepting the command have cost me hoursss…pfff…

Time no have some feedback string FAIL or OK would have been enough…
Ok Now indeed I get a JSON response back just like in all the test cases.

The string is changed to something empty or NULL?? because a IF statement on “” fails.

Why wouldn’t it? It doesn’t know how to spell, a URL can be anything.

If you use API Explorer, you can see what the expected response is.

You are focusing on the cause but i also could have a typo in the device or whatever other typo one can made.

You shoudn’t defend a empty response from a method. I mean how can a response ever be empty? The hole point of a response method is that you get something usefull back.

The answer it should have given back is something like: i don’t have that url → “thing”.

The API explorer don’t uses the same API key and changes : for other characters.

Sometimes it not about right or wrong its about could it be better.
That’s what makes the difference between a good and a great system.

I get an error message back - JSON with an embedded 404 complaint.
Maybe you should investigate why you didn’t - “text/plain” looks suspicious to me.

“text/plain” is what the API Explorer prescribes.
If it would answer with JSON then thats fine too.
It’s what it does anyway now when it works. I only corrected the typo.