Welcome to Smart Home Forum by FIBARO
Dear Guest,
as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.
As a member you can:
- Start new topics and reply to others
- Follow topics and users to get email updates
- Get your own profile page and make new friends
- Send personal messages
- ... and learn a lot about our system!
Regards,
Smart Home Forum by FIBARO Team
Question
Rikbast 3
Hi,
I am trying this HTTP request in HC3 which always returns this statement:
{"error":{"message":"Cast to number failed for value \"NaN\" at path \"__QueryCasting__\" for model \"Ozone1\"","name":"CastError","stringValue":"\"NaN\"","kind":"number","value":"NaN","path":"__QueryCasting__"}}
I also get an 500 error code with this call
This request works flawlessly in HC2, so I am bit lost here. I adapted the HC2 code (hub.debug command only).
Might this be a bug in HC3? I just don't know what's wrong here.
This script has some more code, but that's just handling and data for input of the HTTP request (like token variable). I only copied the HTTP request here.
url:
Please login or register to see this link.
local http = net.HTTPClient({timeout=20000})
function httpGetJson(url, body, func)
http:request(url, {
options = {
method = 'GET',
headers = {
['x-access-token'] = token
},
},
success = function(response)
print(response.data)
hub.debug("Scene6 API response",response.data)
hub.debug("Scene6",response.status)
local isOk, dataTable = pcall(json.decode,response.data)
if (isOk == false) then
func(false, "getResponseData ERROR: Invalid JSON: " .. dataTable ..
"\nWeb Server Data: ".. tostring(response.data))
else
if type(dataTable)=="table" then
func(true, dataTable)
else
func(false, "Data returned by json.decode is not a table")
end
end
end,
error = function(err)
func(false, "HTTPClient error: ".. err)
end
})
end
Any help is appreciated.
thx,
Rik
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.