17

I have a POST request sent to server from robobrowser, and the server responds with no data. The response headers are as follows (this is the response from Chrome browser and it's the way it supposed to be):

Cache-Control:no-cache, no-store, must-revalidate
Content-Length:335
Content-Type:application/json; charset=utf-8
Date:Wed, 02 Aug 2017 17:01:17 GMT
Expires:-1
lg:2673
Pragma:no-cache
Server:Unknown
Set-Cookie:BrandingUserLocationGroupID=ic4DUh/NXVp8VOKAtyDgbA==; expires=Fri, 01-Sep-2017 17:01:16 GMT; path=/; secure; HttpOnly
Set-Cookie:.AIRWATCHAUTH=A69C1A5EE8A5F3626385F35DA1B104EE7DFF5E5AF549DDB02EE8ED53931A0585C0FBB8299E3FC7B428A982B9826EF68390E659F4A74DCE00E195601F400D6E69F53907DADED4194F32DD08A72BA212DCCD0D23AB7C5BD56171E6C55EF1BE90849E9C81B2DAE23B05CA6E361326F44604; expires=Thu, 03-Aug-2017 17:01:17 GMT; path=/; secure; HttpOnly
Strict-Transport-Security:max-age=31536000;includeSubDomains
user:5679
X-Content-Type-Options:nosniff
x-download-options:noopen
x-frame-options:SAMEORIGIN
X-XSS-Protection:1; mode=block

it looks like server is resetting cookies, but my robobrowser instance does not respond/refresh to new cookies. basically, the website is trying to switch sessions/change cookies I think, but my python robobrowser does not reflect that or does not allow it to change for some reason

Here is my POST request and response:

browser=RoboBrowser()
browser.session.headers['X-Requested-With']='XMLHttpRequest'
browser.open('https://example.com/test/Users/set-role?id='+role_id+'&__RequestVerificationToken='+token,method='POST')
print browser.response.content

This gives me the following error message:

{"RedirectUrl":null,"IsSuccess":false,"Message":"Save Failed","CustomMessage":null,"Errors":[{"Key":"","Value":["An error has occurred. This error has automatically been saved for further analysis. Please contact technical support."]}],"Messages":{},"HasView":false,"ViewHtml":null,"ViewUrl":null,"IsValidationException":false,"IsValidationWarning":false,"ReloadPage":false,"IsSessionExpired":false,"Script":null,"NextWizardUrl":null,"PreviousWizardUrl":null,"ShowDialog":false}

Does anyone know how to get robobrowser to respond to new cookies?

Added screenshot of cookie from Developer Tools in Chrome. The red box highlighted is where the change occurs once the link is clicked. enter image description here

BrokenBenchmark
  • 18,126
  • 7
  • 21
  • 33
ikel
  • 1,790
  • 6
  • 31
  • 61
  • if using browser, cookies get changed after post, but not with this robobrowser – ikel Aug 02 '17 at 20:16
  • If you make this same request in curl `curl -X POST 'https://example.com/test/Users/set-role?id=&__RequestVerificationToken=' -H 'x-requested-with: XMLHttpRequest'`, what is the response from the server? – Oluwafemi Sule Aug 10 '17 at 10:28
  • Are you sure cookies are the problem? `robobrowser.open()` is literally just a `requests.Session()` in disguise. The post request should auto update (i.e. - `_update_state(response)`) the session as it was fixed - https://github.com/jmcarp/robobrowser/issues/27. You can also check 2nd answer on this post - https://stackoverflow.com/questions/23737719/how-to-make-post-request-in-robobrowser-python – Dror Av. Aug 10 '17 at 22:57
  • @droravr yeah...im sure it's the cookie part that has issues, because I looked into it from developer tool in chrome and i do see it has few parts changed once clicking on a link and session Id remains same though (maybe thats why robobrowser does not reflect to changes) – ikel Aug 11 '17 at 03:22
  • 1
    Can you try and print your Robobrowser session cookies, to see if the session is actually updating and understand if the problem is with Robobrowser updating itself (in `browser.session.cookies`) or in the session itself not loading the new cookies? – Dror Av. Aug 11 '17 at 07:09

0 Answers0