0

Hello I am facing a weird error I struggle to find solution for.

I have created a code which allows me to fetch data from internet page.

MyRequest.Open "GET", URL
MyRequest.SetRequestHeader "Host", URlHost
MyRequest.SetRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:57.0) Gecko/20100101 Firefox/57.0"
MyRequest.SetRequestHeader "Accept", "image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"
MyRequest.SetRequestHeader "Accept-Language", "pl,en-US;q=0.7,en;q=0.3"
MyRequest.SetRequestHeader "Accept-Encoding", "gzip, deflate, br"
MyRequest.SetRequestHeader "Referer", RefererURL
MyRequest.SetRequestHeader "Connection", "keep-alive"
MyRequest.SetRequestHeader "Upgrade-Insecure-Request", "1"
MyRequest.SetRequestHeader "Cookie", CookieString
MyRequest.send

Response=MyRequest.responsetext

And here is a weird part. Whenever I use CookieString generated by previous requests ( including loging in and search - both sucessfull) this particual request does not work (internal server error). But If I do manual search in Firefox/ IE/ Chrome and copy data from developers tab and paste the cookie obtained there - it works. It is weird because all the other requests where I am using those cookies generated by the code - works and only this one does not. I've tried automatic cookie handling however I was not succesfull as well.

I ve tried Winhttp, msxmlhttp and server versions of them.

Below there are 2 cookies. First copied form Internet Explorer another one generated by code.

   "testcookie=1; JSESSIONID=0F7D44DC25EDC10EFE493825A89A8B6E.3dsprod45; SERVERID=rd727o00000000000000000000ffff89b31ae4o31010"
   "testcookie=1; JSESSIONID=E2F86BBE78B581A3BBAD5DE2D637C4E4.3dsprod41; SERVERID=rd727o00000000000000000000ffff89b31ae4o31002"

Does anyone have any suggestion what might be an issue here?

braX
  • 11,506
  • 5
  • 20
  • 33
KamilG
  • 71
  • 7
  • Run Fiddler and compare headers between your failing request & a successful browser request? Somewhere there will be a difference. – Alex K. Jan 25 '18 at 10:41
  • Maybe I was not clear enough - I am able to make my code request succesfull when I copy cookies from browser request. The only diffrence between failing and succesfull are cookies I am providing. When I provide cookies generated by code - it fails. When I use cookies copied from browser request - sucesfull. – KamilG Jan 25 '18 at 11:31
  • It could be that you are missing a header, but it's probably because the page changes/sets the cookies with some Javascript. – Florent B. Jan 25 '18 at 13:57
  • Thanks for advice however I do not understand, how could I be missing a header while when I use exact same request each time and the only thing changing is way of obtaining the cookies. – KamilG Jan 25 '18 at 14:28
  • Are you saying that you logged in and searched (via the code) successfully? – chillin Jan 25 '18 at 21:58
  • I have logged in with Code sucessfuly and I have obtained a set of cookies that I use for many navigations within The site sucessfuly. However for this nad this only request to make it sucessful I need a set of cookies copied from manual search from browser – KamilG Jan 26 '18 at 12:55

0 Answers0