Kamir Posted September 18, 2023 Share Posted September 18, 2023 Hi, How can I did it? I download files (XML) from internal website. When I type in webbrowser "https://wso2am.ccc.dd:8877/zzz/firm/1.0/get/TTT/2023-09-18?apikey=zzzzzzzzzzzzzz" then the file appears in the browser. I can also download this file using cUrl: curl.exe -k -o tmp\TTT20230918.xml https://wso2am.ccc.dd:8877/zzz/firm/1.0/get/TTT/2023-09-18?apikey=zzzzzzzzzzzzzz I am trying to download this file using WinHttp, but I don't know how. I am trying this: #include "WinHttp.au3" Local $url = "https://wso2am.ccc.dd/zzz/firm/1.0/get/TTT/2023-09-18" Local $api = "?apikey=zzzzzzzzzzzzzz" ; Initialize and get session handle Global $hOpen = _WinHttpOpen() ; Get connection handle Global $hConnect = _WinHttpConnect($hOpen, $url, "8243") If @error Then ConsoleWrite("errA: " & @error & @cr) Else ConsoleWrite("hconnect: " & $hConnect & @cr) EndIf Local $sReturned = _WinHttpSimpleSSLRequest($hConnect, "GET", $api) If @error Then ConsoleWrite("errB: " & @error & @cr) EndIf $hConnect is OK, but I receive error 02 (could not send request) in _WinHttpSimpleSSLRequest Why? What am I doing wrong? Link to comment Share on other sites More sharing options...
Danp2 Posted September 18, 2023 Share Posted September 18, 2023 Have you seen this thread? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Kamir Posted September 18, 2023 Author Share Posted September 18, 2023 yes, I wanted to write my script based on this thread. Link to comment Share on other sites More sharing options...
Danp2 Posted September 18, 2023 Share Posted September 18, 2023 I think you've got modify your URL and key. Try this to see if you get any further -- Local $url = "wso2am.ccc.dd" Local $api = "/zzz/firm/1.0/get/TTT/2023-09-18?apikey=zzzzzzzzzzzzzz" Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Kamir Posted September 18, 2023 Author Share Posted September 18, 2023 the same, connect OK, request - error 2, maybe I should add something to check more precisely what the problem is? Link to comment Share on other sites More sharing options...
Danp2 Posted September 18, 2023 Share Posted September 18, 2023 How do you explain the difference in server port (8877 vs 8243)? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Kamir Posted September 18, 2023 Author Share Posted September 18, 2023 In my original script everything is ok with the port, here I changed the data in order not to make public the real data. With the port came out a little mishap Link to comment Share on other sites More sharing options...
Danp2 Posted September 18, 2023 Share Posted September 18, 2023 The problem is likely due to a security issue (ie: self signed certificate). You could try adding the following prior to the _WinHttpSimpleSSLRequest -- _WinHttpSetOption($hRequest, $WINHTTP_OPTION_SECURITY_FLAGS, BitOR($SECURITY_FLAG_IGNORE_UNKNOWN_CA, $SECURITY_FLAG_IGNORE_CERT_DATE_INVALID, $SECURITY_FLAG_IGNORE_CERT_CN_INVALID, $SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE)) The above was copied from here. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Kamir Posted September 18, 2023 Author Share Posted September 18, 2023 I didn't find this before, but unfortunately it didn't help. Same error 2. Link to comment Share on other sites More sharing options...
Danp2 Posted September 18, 2023 Share Posted September 18, 2023 IDK. 🤷♂️ Hopefully someone else will jump in with some additional ideas for you. Kamir 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Kamir Posted September 18, 2023 Author Share Posted September 18, 2023 but now, I've got error 4 (DllCall failed) after _WinHttpSetOption Link to comment Share on other sites More sharing options...
Kamir Posted September 18, 2023 Author Share Posted September 18, 2023 Thank you for your involvement, if there are further attempts to help - I will check, but I will probably end up using curl. Link to comment Share on other sites More sharing options...
Danp2 Posted September 18, 2023 Share Posted September 18, 2023 29 minutes ago, Kamir said: but now, I've got error 4 (DllCall failed) after _WinHttpSetOption You didn't post your revised code, so we can only make a guess at the problem. Did you fix up the line I posted to fit with your existing code ($hRequest vs $hOpen)? What is your OS? Have you verified that _WinHttpCheckPlatform() returns 1? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Kamir Posted September 18, 2023 Author Share Posted September 18, 2023 Windows 10 64 bit, and 2 yes - I verified that _WinHttpCheckPlatform() returns 1 and of coursce I fix $hRequest to $hOpen. Unfortunately, it is not possible to access this page from outside, so I realize that it is even more difficult to solve the problem. But thank you for your time! Link to comment Share on other sites More sharing options...
robertocm Posted September 20, 2023 Share Posted September 20, 2023 On 9/18/2023 at 4:59 PM, Danp2 said: Hopefully someone else will jump in with some additional ideas for you. Would this be an idea? Googling: WinHttp stunnel Link to comment Share on other sites More sharing options...
robertocm Posted September 25, 2023 Share Posted September 25, 2023 Another possible idea, try with this UDF: http://github.com/jesobreira/HTTP.au3 from: Link to comment Share on other sites More sharing options...
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