Hi all
I would like to read data out of a water softener (BWT Aqua Perla) which has a webinterface in my own LAN. Therefore its needed as a first step to login through POST request to gain the cookie. The cookie is from CAKEPHP. Then a second call to another site on the webapp should return a json string. Nevertheless, I‘m facing the issue, i get the cookie, transfer it to second http request, but it returns a 302 error, indicating that a url redirect happens. msg. payload relay as well on login page...
do you have any ideas, how I can change the second call to get the json information?
The way should be as this:
Login:
Post Request to http://xx.xx.xx.xx/users/login with Content "_method=POST&STLoginPWField=xxxxxx&function=s ave"
—> Response-Cookie "CAKEPHP"
Getting the data with url:
/home/actualizedata
—>response
{"aktuellerDurchfluss":"0","aktuellerDurchflussProzent":"0","durchflussHeute":"0","durchflussMonat":"0","durchflussJahr":"0","RegeneriemittelNachfuellenIn":"0","RegeneriemittelVerbleibend":"0"}
This is the code for the nodes.
[{"id":"da556b4c.191f68","type":"tab","label":"BWT Perla Seta","disabled":false,"info":""},{"id":"7d4a8e14.598fd","type":"debug","z":"da556b4c.191f68","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"responseUrl","targetType":"msg","statusVal":"","statusType":"auto","x":1170,"y":240,"wires":[]},{"id":"718329ef.af2aa","type":"inject","z":"da556b4c.191f68","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":340,"wires":[["7b705cf5.8d7644"]]},{"id":"fc22ddec.3cea4","type":"debug","z":"da556b4c.191f68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"responseCookies","targetType":"msg","statusVal":"","statusType":"auto","x":760,"y":160,"wires":[]},{"id":"7b705cf5.8d7644","type":"function","z":"da556b4c.191f68","name":"","func":"msg.headers = \n{ \"Content-Type\" : \"application/x-www-form-urlencoded\" ,\n\"Origin\": \"https://192.168.1.189\",\n\"Host\": \"192.168.1.189\",\n\"Referer\": \"https://192.168.1.189/users/login\",\n\"Upgrade-Insecure-Requests\": \"1\",\n\"STLoginPWField\": \"dzfuqv\",\n\"function\":\"save\"}\nmsg.rejectUnauthorized = false;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":280,"y":240,"wires":[["52fd04b6.7857ac"]]},{"id":"52fd04b6.7857ac","type":"http request","z":"da556b4c.191f68","name":"login","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://192.168.1.189/","tls":"","persist":false,"proxy":"","authType":"","x":450,"y":240,"wires":[["fc22ddec.3cea4","b5f435fd.62b8"]]},{"id":"b5f435fd.62b8","type":"function","z":"da556b4c.191f68","name":"","func":"msg.headers = {\n \"Host\": \"192.168.1.189\",\n \"Upgrade-Insecure-Requests\": 1,\n \"STLoginPWField\": \"dzfuqv\",\n \"function\":\"save\"\n};\nmsg.cookies = msg.responseCookies;\nmsg.rejectUnauthorized = false;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":735.3333129882812,"y":240.33334350585938,"wires":[["c330713d.f7513","7a461eae.0028c"]]},{"id":"c330713d.f7513","type":"http request","z":"da556b4c.191f68","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://192.168.1.189/home/actualizedata/","tls":"","persist":false,"proxy":"","authType":"","x":950,"y":240,"wires":[["7d4a8e14.598fd","9621282.0604158","853b6de9.7ecd5"]]},{"id":"7a461eae.0028c","type":"debug","z":"da556b4c.191f68","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"cookies","targetType":"msg","statusVal":"","statusType":"auto","x":960,"y":400,"wires":[]},{"id":"9621282.0604158","type":"debug","z":"da556b4c.191f68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1160,"y":380,"wires":[]},{"id":"853b6de9.7ecd5","type":"debug","z":"da556b4c.191f68","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"cookies","targetType":"msg","statusVal":"","statusType":"auto","x":1150,"y":180,"wires":[]}]
Thanks a lot for your assist
Thomas