title: Jupyter: XSRF cookie does not match POST
body: <p>I am trying to transfert files using a python program running on a local Anaconda to a local Jupyter within a docker container using the Jupyter rest API.</p>
  
  <p>I managed already to execute a requests.get() succesfully after muddling-through a bit on how to input the token.</p>
  
  <p>Now I would like now to execute a requests.post() command to transfert the files.</p>
  
  <p>Configuration:</p>
  
  <ol>
  <li><p>local docker container running on docker toolbox for windows</p>
  
  <ul>
  <li>docker version 17.04.0-ce, build 4845c56</li>
  <li>tensorflow/tensorflow incl. Jupyter latest version install</li>
  <li>jupyter_kernel_gateway==0.3.1</li>
  </ul></li>
  <li><p>local Anaconda v. 4.3.14 running on a windows 10 machine</p></li>
  </ol>
  
  <p>Code:</p>
  
  <pre><code>token = token_code_provided_by_jupyter_at_startup
  api_url = "http://192.168.99.100:8888/api/contents"
  # getting the file's data from disk and converting into a json file
  cwd = os.getcwd()
  file_location = cwd+r'\Resources\Test\test_post.py'
  payload = open(file_location, 'r').read()
  b64payload = base64.encodestring(payload)
  body = json.dumps({
              'content':b64payload,
              'name': 'test_post.py',
              'path': '/api/contents/',
              'format': 'base64',
              'type':'file'
          })
  # getting the xsrf cookie
  client = requests.session()
  client.get('http://192.168.99.100:8888/')
  csrftoken = client.cookies['_xsrf']
  headers ={'Content-type': 'application/json', 'X-CSRFToken':csrftoken, 'Referer':'http://192.168.99.100:8888/api/contents', 'token':token}
  response = requests.post(api_url, data=body, headers=headers, verify=True)
  </code></pre>
  
  <p>Error returned</p>
  
  <blockquote>
    <p>[W 12:22:36.710 NotebookApp] 403 POST /api/contents (192.168.99.1): XSRF cookie does not match POST argument
    [W 12:22:36.713 NotebookApp] 403 POST /api/contents (192.168.99.1) 4.17ms referer=<a href="http://192.168.99.100:8888/api/contents" rel="nofollow noreferrer">http://192.168.99.100:8888/api/contents</a></p>
  </blockquote>