Jump to content

[ERROR] AutoIT can't handle HTTP requests? The requested action with this object has failed


Go to solution Solved by Jos,

Recommended Posts

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

Link to comment
Share on other sites

  • Developers

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! ;) 

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.
  :)

Link to comment
Share on other sites

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 by Zedna
Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Developers
  • Solution
1 hour ago, Femboy said:

 I see you can't take jokes.

Guess we can shake hands on that one. 😉

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.
  :)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...