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


  • 0

Virtual device, http-POST, xml (Switching off a Sony TV)


Question

Posted

Hi there,

I am a newbie and would like to ask for help in a simple http POST.

I need to send a http-POST request formed as that:

URL:

Please login or register to see this code.

http-header:

Please login or register to see this code.

http-POST:

Please login or register to see this code.

I have read how to use a GET request. GET seems to be much simpler. Can you help?

best regards

Rolf

P.S.: This should be the request to turn off a Sony TV via network. Turning on is via Wake on LAN and already works quite well.

7 answers to this question

Recommended Posts

  • 0
Posted

GET is just a url request, it contains no body, so it is no different from entering an address in the address bar of your browser.

For POST request, you need a well formed header telling the receiver what the content type is and any other custom header (as the one you have above) Go online and find a HTTP-request generator. That is the easiest way to form the POST request correctly, then you can always reverse engineer the code if you want to change it. Also remember to ensure that if you need a password to access the TV that you set the authentification correctly.

I'm not sure however, that the HC2 supports the custom headers out of the box though. I know that there is a "Lua framework" on the forum which should give you the possibility of adding custom headers, but I'm not sure it works without this add-on.

  • 0
Posted

On V3.5xx you should use my lua frameworks or make your request with Net.FTcp, also look here:

Please login or register to see this link.

  • 0
  • Inquirer
  • Posted

    Thanks a lot. Therefore it seems to look like this (not tested):

    Please login or register to see this code.

    Will test it when I'm back @home.

    [ Added: 2014-11-18, 16:47 ]

    Hmm, doesn't work. Did I miss something here? Do I probably need to put

    Please login or register to see this code.

    before the "

    • 0
    Posted

    Hmm, doesn't work. Did I miss something here? Do I probably need to put

    Please login or register to see this code.

    before the "

    Many parsers won't accept xml which isn't well formed and valid. Have a look at some of the information on XML basics for more information on this. It won't be well formed if you don't have the <?xml> declare function at the very beginning of the documents without any sort of whitespaces ahead of it. If you don't declare the document as xml, it probably won't be parsed correctly.

    Have you tried sending the request from a request handler on a PC and checked the response? The Sony TV will respond with an error message if your request body isn't accepted and this might help you understand why it isn't working.

    • 0
  • Inquirer
  • Posted

    I'm somewhat stuck now since I cannot get this to work on my Macbook. Probably I get a response from the Sony TV which I don't see in the HC2. Is there a way to get responses in LUA?

    • 0
    Posted

    rowi, in LUA you can do something like:

    Please login or register to see this code.

    If that is what you mean.

    • 0
  • Inquirer
  • Posted

    I have seen several examples with the "response, status, errorcode", but am obviously too dumb to include the headers as above.

    Besides this for the Sony TV I figured out that there is a cookie as password which is needed. Since I cannot do a tcpdump on the HC2 (this would be awesome) and am in a switched network, it is a bit harder to sniff the network traffic. Anybody with a clue here? Should have kept the old network hubs..

    Join the conversation

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

    Guest
    Answer this question...

    ×   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...