title: curl to python requests error: "no api key supplied"
body: <p>I'm trying to do a curl command with python requests. As far as I can tell I'm doing everything correctly but the website won't recognize the api key no matter how I try to include it. Basically, the site I'm trying to reach wants the api key put in the beginning of the url. When I do this with curl, it works perfectly. When I try it via python requests, however, it doesn't work. It also doesn't work to send it in as a key-value pairing in dictionary.</p>
  
  <p>This works</p>
  
  <pre><code>curl -H "Content-Type:application/json" -d '{"ndbno":["11124"],"type":"f"}' [API KEY]@api.nal.usda.gov/ndb/V2/reports
  </code></pre>
  
  <p>and here's the requests code:</p>
  
  <pre><code>import requests
  
  headers = {'Content-Type': 'application/json',}
  
  data = '{"ndbno":["11124"],"type":"f"}'
  
  response = requests.post('http://[API KEY]@api.nal.usda.gov/ndb/V2/reports', headers=headers, data=data)
  </code></pre>
  
  <p>The result from this is a json response containing the message: "{'error': {'code': 'API_KEY_MISSING', 'message': 'No api_key was supplied. Get one at <a href="http://api.nal.usda.gov:80" rel="nofollow noreferrer">http://api.nal.usda.gov:80</a>'}}
  "</p>
  
  <p>It also doesn't work if I remove the [API KEY] from the url and add it to the data dictionary as "api_key":"[API KEY]"</p>
  
  <p>BTW I'm not passing the key in as a list or anything, I just didn't want to post the physical key in my question.</p>
  
  <p>I'm a total newb to python and stackoverflow, but I've done my due diligence and have been searching out answers and testing different ways to format the request for a few hours now. Any help is greatly appreciated!</p>