Jump to content

Send Json in http request ?


Acce
 Share

Recommended Posts

So im trying to send a json string in my http request but something is wrong , not entireley sure where but the response I get from the server is this:

 [{"title":"Exception","message":"Sorry, an internal error occurred. Please try again later","__class__":"Error"}] 

Which leads me to belive that the json string I send over in the request might be formatted incorrectly. Here is the code I´m running to get this line  

;// open
Global $hRequest = _WinHttpOpenRequest($hConnect, _
        "POST", _ ;verb
        gatewayUrl, _ ;Target
        Default, _ ;Version
        "/index?", _ ;referer
        "*/*", _
        $WINHTTP_FLAG_SECURE)
    ;Set Request Headers
_WinHttpAddRequestHeaders($hRequest, "Content-Type: application/json")
_WinHttpAddRequestHeaders($hRequest, "Client-Identification: version=1.184; requiredVersion=1.184; platform=bro; platformType=html5; platformVersion=web")
_WinHttpAddRequestHeaders($hRequest, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36")
_WinHttpAddRequestHeaders($hRequest, "Content-Type: application/json")
    ;ConsoleWrite("Response Headers start/index"& @CRLF)
;ConsoleWrite("start/index" & $token_login& @CRLF)
    ;json Request
Global $payload = '[{"__class__":"ServerRequest","requestData":[],"requestClass":"StartupService","requestMethod":"getData","requestId":1}]'
    ; Send it
_WinHttpSendRequest($hRequest, -1, $payload)
    ; Wait for the response
_WinHttpReceiveResponse($hRequest)
    ; Headers
_GetHeaders("Response Headers Json")
    ;Response
_GetResopnse("Server Response?")

 

Does this look correct to you guys? Im real uncertain if im sending the Json string correctley over to the server, If that is correct I guess might be missing a session token or something like that...

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