title: Using an access_token to make a POST request to Facebook's Graph API
body: <p>Facebook's documentation on creating a test lead for leadgen is fairly lackluster. However, they provide some cURL commands that are useful, and seem to get the job done: </p>
  
  <pre><code>curl \
  -F "access_token=&lt;ACCESS_TOKEN&gt;" \
  "https://graph.facebook.com/&lt;API_VERSION&gt;/&lt;FORM_ID&gt;/test_leads"
  </code></pre>
  
  <p>and</p>
  
  <pre><code>curl \
  -F "field_data=[{'name': 'favorite_color?', 'values': ['yellow']}, {'name': 'email', 'values': ['test@test.com']}]" \
  -F "custom_disclaimer_responses=[{'checkbox_key': 'my_checkbox', 'is_checked': true}]" \
  -F "access_token=&lt;ACCESS_TOKEN&gt;" \
  "https://graph.facebook.com/&lt;API_VERSION&gt;/&lt;FORM_ID&gt;/test_leads"
  </code></pre>
  
  <p>Like I said, this works for me. However, I would like to know how to make this request using Python's <code>requests</code> library and their <code>post</code> method. </p>
  
  <p>This is the code I'm using:</p>
  
  <pre><code>token = "&lt;MY_TOKEN"
  url = "https://graph.facebook.com/&lt;MY_API_VERSION&gt;/&lt;MY_FORM_ID&gt;/test_leads"
  
  r = requests.post(url, headers={'access_token': token})
  </code></pre>
  
  <p>I can't seem to get this request through using Python (returning <code>"code":100,"error_subcode":33</code> from Facebook), but it works just fine using cURL. What can I do to get this request to work using my Python script. </p>
  
  <p>EDIT: In conjunction with my question on how to pass the access token with my Post request, how would I go about passing the other things they show in their example, e.h., <code>field_data</code>, and <code>custom_disclaimer_responses</code>?</p>
  
  <p>EDIT2: If I use the URL <code>"https://graph.facebook.com/&lt;MY_API&gt;/&lt;MY_FORM_ID&gt;/test_leads?access_token="+token</code> the request goes through nice and easy. I just can't seem to pass it through headers. </p>