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!



Smart Home Forum by FIBARO Team

  • 0

API Token gets corrupted in LUA





I have access to an API towards my Solarsystem which im trying to setup.

To get to the actual data i need to first get a Token by providing username/pass which i then use to send together with the next request and this is where it stops.

I can do the same thing in Postman and it works.


The Token can look something like this:



When i print this out in a scene before using it i can see it always performs a line feed after the first '-' in the string.

When examine the string in notepad++ there is no \r or \n (CR|LF) but somehow, something is happening with the Token string and i suspect that this is the problem..


Im saving the Token as a global var and then use it in the header (xsrfToken):

options = {
                headers = {["XSRF-TOKEN"] = tostring(xsrfToken), ['Content-Type'] = 'application/json'},
                method = 'POST',
                checkCertificate = false,
                data = json.encode(pLoad)


Maybe someone has met the same problem?



Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • After some more investigation i found that the token is correct, but reading some more in this forum it is probably due to the header, XSRF-TOKEN, that is not supported..

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Hi again..


    I have tried some more to get this working and since its failing when using requests from Fibaro Scene i tried to setup a simple console app in VS to run the same requests (using RestSharp) with C# but i get the same response:



    There is no problem getting the Token but when trying to use it in the next request, i just cant get pass this failure..


    So i´m hoping there is someone good at HTTP Requests and can spare a couple of minutes to help out (I really want this working ;( )


    Here is what i have to do:

    Please login or register to see this link.


    And its working in PostMan but i´m probably doing something wrong, just cant figure out what!


    5.     Interface of Plant List

    .. is where im stuck..


    Really would appreciate any help, Thanks!

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Its working with RestSharp after i added some cookies from the first request but how do i add cookies in lua to make this work from HC2?

    Link to comment
    Share on other sites

    Join the conversation

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

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