Jump to content

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


Problems with format variable response of http:request()


Recommended Posts

Posted

 Hello everybody !

 

I post here because, since few weeks ago, I have a problem with the format of the variable "response" with the function http:request() (on PushBullet website).

 

In the callback "success" function :

 

The "response.data" is :

 

Please login or register to see this code.

 

The "response.status" give me "1" instead "200" !

I don't have "response.headers" !

 

 

And logically, if I use this traditional callback code :

Please login or register to see this code.

 

I have an error

 

Please login or register to see this code.

 

It looks like a bug with the function http:request() no ?

 

 

 

to bypass this bug, I use this :

 

Please login or register to see this code.

 

And to use the fields "devices" from the json, I must do a string.sub() of this json after "Connection: close"

It's boring !! and not correct !!

 

 

 

does anyone have a solution for this bug ?

 

best regards !

 

 

 

Posted

could you please post the entire response of the request?

Posted (edited)

In a scene you get a "bad status" error message from pushbullet ;-) 

Because (almost) no one else seems to have problem with net.HTTPClient I would guess that it's either some of pushbullet's headers that the lua library stumbles on (HC3's fault), or some missing \r\n in the response (pushbullet's fault), where other http libraries sometimes are more forgiving.... (no one at stack overflow seems to have this issue with pushbullet)

 

I made a try from my

Please login or register to see this link.

, and it worked of course - but there the net.HTTPClient is implemented using the python library....

 

Just tested it on the TQAE emulator that uses the luasocket+http library and it worked there too. Would be surprised if the HC3 uses something else, but maybe they do.

 

It starts to lean towards a HC3 bug.

Edited by jgab
  • Topic Author
  • Posted

    @cag014 here the entire response (I delete the data in "devices")

    It's print with json.encode(),so sorry for the syntax...

    I don't change the format, it's plain text.

     

    Please login or register to see this code.

     

    @jgab when I have time, I will try with another system and I'll can see if it'll work...

    Posted
    2 hours ago, jjacques68 said:

    @cag014 here the entire response (I delete the data in "devices")

    It's print with json.encode(),so sorry for the syntax...

    I don't change the format, it's plain text.

     

    Please login or register to see this code.

     

    @jgab when I have time, I will try with another system and I'll can see if it'll work...

    Strange indeed.

    Just to verify that this is not a bug in HC2, could you please try below url 

    "http://worldtimeapi.org:80/api/ip"

    Should return some time info.

    Posted (edited)
    10 hours ago, jjacques68 said:

    @cag014 here the entire response (I delete the data in "devices")

    It's print with json.encode(),so sorry for the syntax...

    I don't change the format, it's plain text.

     

    Please login or register to see this code.

     

    @jgab when I have time, I will try with another system and I'll can see if it'll work...

    as I said in my post - I tried it on 2 other systems and it worked as a charm. So I believe it will work on other systems you test (as long as it's not Fibaro) - reason being that the Pushbullet developer community is reasonable large and there is no complaint about the API in this matter.

    Unfortunately, the intersection between Pushbullet developers and Fibaro developers seems to be just you, so the sample is not so large, but I would say it's a Fibaro problem.

    In any case the QA should not give that response, and the Scene I tested gave "bad status" which is probably the '1' that the QA returns.

     

    Edited by jgab
    • 1 year later...
    Posted (edited)

    I ran into this same issue with the Fronius QuickApp recently.

    My workaround was to create a function to parse the response if it's bugged, or process as per usual if the response is correctly formatted.

     

    The code for processing the headers might not produce the correct output but for my purposes I just needed the response.status and response.data to be valid.

     

    Please login or register to see this code.

     

    Edited by BlueSmurf

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...