title: Sniffing http then using python requests to make same call
body: <p>Instagram insights isn't offered on desktop so in order to get round this I set up mitm proxy and have sniffed the http requests that take place between instagram and my phone when I log in to insights.</p>
  
  <p><a href="https://i.stack.imgur.com/NPFPR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NPFPR.png" alt="This is the post request made to login"></a></p>
  
  <p>How do I re-engineer this so I can use the same command with the requests library in Python?
  This is what I've tried so far... but I keep getting a 'failed' due to not being logged in.</p>
  
  <pre><code>import json
  
  headers = {"Content-Type": "application/json"}
  payload = {"username":"souXXX","password":"XXXX","_csrftoken":"XXXXXXn2fIQfrQXXXXXn"}
  
  
  r = requests.post("https://i.instagram.com/api/v1/accounts/login/", data=payload, headers=headers)
  </code></pre>
  
  <p>I've spent aaaages trying to get this work, and I'm not really sure what I'm doing wrong. As such, I'd love some advice/guidance.</p>
  
  <p>Thanks in advance!</p>