title: Request to EdgeCast REST API from Python return 405 'Method not allowed'
body: <p>I'm trying to automate purging of files on Edgecast through their REST API.</p>
  
  <p>This code works within a Bash script:</p>
  
  <pre><code>curl -s  -H "Authorization: tok:$EC_AUTH_TOKEN" -H 'Accept: application/json' -H 'Content-Type: application/json' -X PUT -d "{ \"MediaPath\":\"$PURGE_PATH\", \"MediaType\":3 }"  https://api.edgecast.com/v2/mcc/customers/$ACCT_ID/edge/purge
  </code></pre>
  
  <p>But this Python version does not:</p>
  
  <pre><code>def purge_file(file_path):
  buff = StringIO()
  c = pycurl.Curl()
  post_data = {'MediaPath': file_path, 'MediaType': 3}
  # Form data must be provided already urlencoded.
  postfields = json.dumps(post_data, separators=(',', ':'))
  c.setopt(c.POSTFIELDS, postfields)
  c.setopt(c.URL, PURGE_URL)
  c.setopt(pycurl.HTTPHEADER, ['Authorization: tok:' + EC_AUTH_TOKEN,
                               'Accept: application/json',
                               'Content-Type: application/json'])
  c.setopt(c.WRITEDATA, buff)
  c.perform()
  c.close()
  body = buff.getvalue()
  print (body)
  </code></pre>
  
  <p>Nor does this:</p>
  
  <pre><code>def purge_file(file_path):
  values = {'MediaPath': urllib.quote_plus(file_path),
            'MediaType': 3}
  post_data = json.dumps(values, separators=(',', ':'))
  request = urllib2.Request(PURGE_URL, data=post_data, headers={'Accept': 'application/json',
                                                                'Content-Type': 'application/json',
                                                                'Authorization': 'tok:' + EC_AUTH_TOKEN})
  response = urllib2.urlopen(request)
  print response.read()
  </code></pre>
  
  <p>Both of the Python versions return an error 405: Method not allowed.</p>
  
  <p>Thanks for any help!</p>