Jump to content

Recommended Posts

Hello, nice to meet you,

I have tested two different ways to send a GET request to a server based on 

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)

If _WinHttpQueryDataAvailable($h_openRequest) Then
    $data = ""
    While 1
        $chunk = _WinHttpReadData($h_openRequest, 1)
        If Not @extended Then ExitLoop
    ;ConsoleWrite($chunk & @CRLF)
        $data &= $chunk
    ConsoleWrite($data & @CRLF)


#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( StringLeft($sReturned, 1100) & "...")

; Close handles


Edited by ChessMate
Link to post
Share on other sites
  • ChessMate changed the title to WinHTTP token sending
  • 2 weeks later...

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

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