POST API Request not Identical to running locally - 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: POST API Request not Identical to running locally (/showthread.php?tid=4558) |
POST API Request not Identical to running locally - ks04 - 06.02.2023 Hi There, I have an iZone AC unit which I can query off API POST commands however am having issues getting the same result from the LM device (SHAC). I am able to send POST commands fine via postman and receive the expected result, and installed LUA on my mac and was able to get the expected result, however, I am getting an error response back from the target device. Has anyone encountered anything similar? Does the LM device add any additional gumph or formatting into the POST request which might be throwing this off? Open to all ideas (Note, I also tried running LUA 4.1 locally and got the same result as running the later version) RE: POST API Request not Identical to running locally - admin - 06.02.2023 Can you post the raw request that is sent from Postman? Some devices can't understand certain headers or headers must be in a specific case. LM use canonical header format. Lua version does not matter, but check which LuaSocket version you have: Code: print(require('socket')._VERSION) RE: POST API Request not Identical to running locally - ks04 - 06.02.2023 (06.02.2023, 11:59)admin Wrote: Can you post the raw request that is sent from Postman? Some devices can't understand certain headers or headers must be in a specific case. LM use canonical header format. LuaSocket version on LM is 2.0.2 vs locally is 3.0.0 so this could be contributing to the difference in experience. Here's the raw postman request: Code: {"iZoneV2Request": {"Type": 1,"No": 0,"No1": 0}} RE: POST API Request not Identical to running locally - admin - 07.02.2023 Try this: Code: http = require('socket.http') RE: POST API Request not Identical to running locally - ks04 - 08.02.2023 (07.02.2023, 08:02)admin Wrote: Try this: Sadly, same error Code: Event for 0/56/180 08.02.2023 11:24:21 RE: POST API Request not Identical to running locally - admin - 08.02.2023 One more thing to try is to send a request using raw sockets. Modify host, uri and body as needed. Code: host = '192.168.0.9' RE: POST API Request not Identical to running locally - ks04 - 08.02.2023 Success! Thanks so much - that's been bugging me for ages now! Would love to know why the original approach doesn't work, but will take the win! |