Post Request with XML request body - 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 Request with XML request body (/showthread.php?tid=5493) |
Post Request with XML request body - Hadeel - 03.07.2024 I am trying to send the following command to SONY Bravia TV with REST API request. While I successfully sent the exact same command with XML request body with Postman, when I try with LM I am getting 500 Internal Server Error. Am I missing something in my code? Code: local http = require("socket.http") The example code from SONY Bravia official is the follwoing. https://pro-bravia.sony.net/ja/develop/integrate/ircc-ip/overview/index.html#authentication Thank you for your help in advance! RE: Post Request with XML request body - admin - 04.07.2024 Host header is not needed (it also does not match the IP of your TV). Content-Type is different from the docs, should be text/xml; charset=UTF-8 Also try removing ["Connection"] = "Keep-Alive", as it's not supported by the library. If it still does not work the try exporting Postman request that works in Curl format and post it here. RE: Post Request with XML request body - Hadeel - 04.07.2024 Thank you admin! I removed Host, Connection headers and changed Content-Type but it is not working... This is the Curl request that works successfully. Code: curl --location 'http://172.16.1.11/sony/ircc' \ RE: Post Request with XML request body - admin - 04.07.2024 Looks like SOAPACTION header value must be also contain double quotes: Code: ["SOAPACTION"] = [["urn:schemas-sony-com:service:IRCC:1#X_SendIRCC"]], Not sure if it matters but your script has a different IRCCCode value compared to the Postman/Curl. RE: Post Request with XML request body - Hadeel - 04.07.2024 Ohhh exactly, it worked ..... !! Thank you so much for your quick help!! Oh yes I am trying with several IRCCCode but they all work now....appreciate you a lot as always! |