Femboy Posted April 4, 2024 Posted April 4, 2024 Hello y'all, At my workplace, I've been tasked to make some software with AutoIT and I seem to be stuck with this: $orionURL = 'http://'&$ipAddress&':5001/' $jsonData = '[{ "request": { "TokenName": "bitCMDGrantEnter", "LaneNumber":"'&$laneNumber&'", "Value": "true"}}]' $oHTTP = ObjCreate("MSXML2.XMLHTTP") $oHTTP.Open("POST", $orionURL, False) $oHTTP.SetRequestHeader("Content-Type", "application/json") ; ----ERRROR RIGHT HERE--------- $oHTTP.Send($jsonData) The console logs show the URL, IP address, Lane number and everything else to be perfect. I've sent the same requests on postman and it works wonders, even when spammed on the same computer, everything in the JSON and URL to be the same and it works like butter. but AutoIT seems to just struggle with this request, its a 50% flip of a coin for it to work well or bring up this error everytime: (833) : ==> The requested action with this object has failed.: $oHTTP.Send($jsonData) $oHTTP^ ERROR I've also tried using "WinHttp.WinHttpRequest.5.1" for my HTTP request but the difference seems null. Am I blind? I've tried all types of error catching, COM error catching and nothing... THANK YOU SO MUCH FOR YOUR TIME! I hate AutoIT
Developers Jos Posted April 4, 2024 Developers Posted April 4, 2024 There seems to be a huge discrepancy between the end of your post and the chosen footer text. So my current answer would be: Quote THANK YOU SO MUCH FOR YOUR TIME! Will have a look for you... Quote I hate AutoIT Well, maybe not, and am sure you can figure it out yourself! Melba23 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Zedna Posted April 4, 2024 Posted April 4, 2024 (edited) Add COM/OLE error checking to see error description and avoid hard crash ... $objErr = ObjEvent("AutoIt.Error","MyErrFunc") $orionURL = 'http://'&$ipAddress&':5001/' $jsonData = '[{ "request": { "TokenName": "bitCMDGrantEnter", "LaneNumber":"'&$laneNumber&'", "Value": "true"}}]' $oHTTP = ObjCreate("MSXML2.XMLHTTP") $oHTTP.Open("POST", $orionURL, False) $oHTTP.SetRequestHeader("Content-Type", "application/json") $oHTTP.Send($jsonData) ; ----ERRROR RIGHT HERE--------- If @error Then Exit ; ... Func MyErrFunc() MsgBox(48, 'COM Error', $objErr.description) SetError(1) EndFunc Edited April 4, 2024 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Femboy Posted April 5, 2024 Author Posted April 5, 2024 On 4/4/2024 at 10:17 AM, Zedna said: Add COM/OLE error checking to see error description and avoid hard crash ... $objErr = ObjEvent("AutoIt.Error","MyErrFunc") $orionURL = 'http://'&$ipAddress&':5001/' $jsonData = '[{ "request": { "TokenName": "bitCMDGrantEnter", "LaneNumber":"'&$laneNumber&'", "Value": "true"}}]' $oHTTP = ObjCreate("MSXML2.XMLHTTP") $oHTTP.Open("POST", $orionURL, False) $oHTTP.SetRequestHeader("Content-Type", "application/json") $oHTTP.Send($jsonData) ; ----ERRROR RIGHT HERE--------- If @error Then Exit ; ... Func MyErrFunc() MsgBox(48, 'COM Error', $objErr.description) SetError(1) EndFunc @Zedna thank you so much!! I already had a COM error checking but completely forgot that I could Exit after grabbing the error. @Jos I see you can't take jokes. I hate AutoIT
Developers Solution Jos Posted April 5, 2024 Developers Solution Posted April 5, 2024 1 hour ago, Femboy said: I see you can't take jokes. Guess we can shake hands on that one. 😉 Femboy 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now