http.request more then 1 command in the same session - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: http.request more then 1 command in the same session (/showthread.php?tid=1921) |
http.request more then 1 command in the same session - gjniewenhuijse - 18.02.2019 How to execute more then one http request in the same web sessions? Code: function openDoor(iLoxxId) I have a request for login and another request for opening the door. But now i received: 401 Authorization Required If i execute both statements in the browser it works. RE: http.request more then 1 command in the same session - Erwin van der Zwart - 18.02.2019 Hi, You probably get a response in the first request that you need to add to the headers of the second request. RE: http.request more then 1 command in the same session - gjniewenhuijse - 19.02.2019 (18.02.2019, 23:02)Erwin van der Zwart Wrote: Hi, Maybe, but when i execute this statements in the same browser tab it works, so i think it has nothing todo with headers. Or how to find this out? RE: http.request more then 1 command in the same session - admin - 19.02.2019 Erwin is correct. Try logging response headers: Code: url = ... Logged headers should contain "set-cookie" field which then should be parsed and passed as "cookie" header to next request. This post has a similar example though first request is different since login token is in response JSON body: https://forum.logicmachine.net/showthread.php?tid=993&pid=5774#pid5774 RE: http.request more then 1 command in the same session - gjniewenhuijse - 19.02.2019 (19.02.2019, 08:12)admin Wrote: Erwin is correct. Try logging response headers:Thanx admin and Erwin This it the hdrs output: * table: [set-cookie] * string: SESSION=23136A000858325C; [content-type] * string: text/plain RE: http.request more then 1 command in the same session - admin - 19.02.2019 So then you just need to pass cookie header to the next request: Code: require('socket.http') RE: http.request more then 1 command in the same session - gjniewenhuijse - 19.02.2019 (19.02.2019, 09:16)admin Wrote: So then you just need to pass cookie header to the next request: Yeah, thanks it works!! |