Jump to content

Recommended Posts

Posted


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?

Posted

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

Posted

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.

Posted

Thank you for your involvement, if there are further attempts to help - I will check, but I will probably end up using curl.

Posted

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!

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
  • Recently Browsing   0 members

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