ChessMate 1 Posted January 17 Share Posted January 17 (edited) Hello, nice to meet you, I have tested two different ways to send a GET request to a server based on https://www.autoitscript.com/forum/topic/84133-winhttp-functions/page/2/#comments The two works and communicate with the server. However, I still can't figure out how to properly send the token as I always get the error displayed below. Could you please tell me where I did something wrong (and which script is best fort this purpose) ? Here are the two scripts I have tested so far : #include "WinHTTP.au3" ; Initialize and get session handle $hw_open = _WinHttpOpen() ; Get connection handle $hw_connect = _WinHttpConnect($hw_open, "replaced.fr") $h_openRequest = _WinHttpOpenRequest($hw_connect, "GET", "api/user/details", "HTTP/1.1") Local $sToken = "abolutelyafake" Local $sAccept = "*/*" $nonoptionalDATA = 'accept=' & $sAccept & 'X-CSRF-TOKEN=' & $sToken _WinHttpSendRequest($h_openRequest, Default, $nonoptionalDATA) _WinHttpReceiveResponse($h_openRequest) If _WinHttpQueryDataAvailable($h_openRequest) Then $data = "" While 1 $chunk = _WinHttpReadData($h_openRequest, 1) If Not @extended Then ExitLoop ;ConsoleWrite($chunk & @CRLF) $data &= $chunk WEnd ConsoleWrite($data & @CRLF) EndIf _WinHttpCloseHandle($h_openRequest) _WinHttpCloseHandle($hw_connect) _WinHttpCloseHandle($hw_open) #include "WinHttp.au3" Opt("MustDeclareVars", 1) ; Initialize and get session handle Global $hOpen = _WinHttpOpen() ; Get connection handle Global $hConnect = _WinHttpConnect($hOpen, "replaced.fr") Local $sToken = "abolutelyafake" Local $sAccept = "*/*" Local $sRDATA = 'accept=' & $sAccept & 'X-CSRF-TOKEN=' & $sToken Local $sReturned = _WinHttpSimpleSSLRequest($hConnect, "GET","api/user/details",Default, $sRDATA ,Default,Default,Default) ConsoleWrite("Test") ConsoleWrite( StringLeft($sReturned, 1100) & "...") ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Edited January 19 by ChessMate Link to post Share on other sites
ChessMate 1 Posted February 2 Author Share Posted February 2 Hello, as I dont have any answer, did I ask incorrectly ? I asked this question two weeks ago because I could not find any answer anywhere on this forum. I am sure my token is correct because the owner of the website I am interrogating provide it directly once logged in. So it is just the exact way to send it as a parameter which seems to be the problem. Link to post Share on other sites
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