Jump to content
Sign in to follow this  
KeshHERE

Getting Chuncked Encoding Type JSON response via Http Post

Recommended Posts

KeshHERE

Here is the script I am using for getting response from below website.

$loginurl ="http://mcqdb.com/api/problemaccess/GetAdaptiveNextProblem/?gradeId=PrePG&subjectId=Medicine"


$login = ObjCreate("winhttp.winhttprequest.5.1")
$login.Open("POST",$loginurl, False)
$login.SetRequestHeader('User-Agent','Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0')
$login.SetRequestHeader('Content-Type', 'application/json; charset=utf-8')
$login.SetRequestHeader('Accept', 'application/json; charset=utf-8')
$login.SetRequestHeader('Accept-Encoding', 'gzip, deflate')
$login.SetRequestHeader('Accept-Language', 'en-US,en;q=0.5')
$login.SetRequestHeader('Referer', 'http://mcqdb.com/')
$login.SetRequestHeader('Content-Length', '2')
$login.SetRequestHeader('Connection', 'close')
$login.Send()


MsgBox(0,'hi',$login.responseText)

This request is going without a problem and returning needed response when i see it in WIRESHARK.

But responseText does not seem to be what i want. Valid Response which I want is in JSON (As you can see in WIRESHARK) but it is not the case with responseText.

What have I done wrong? Is it because that response encoding-Type is Chunked? If yes, How can I get JSON response back?

Edited by KeshHERE

Share this post


Link to post
Share on other sites
KeshHERE
9 hours ago, Danp2 said:

Try commenting out this line --

$login.SetRequestHeader('Accept-Encoding', 'gzip, deflate')

 

Works like a charm.. thanks 😉😉

Share this post


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
Sign in to follow this  

×