title: How to take values from file while posting form data using python or pycurl
body: <p>One of my text contains say smaple.txt 
  1234
  4567
  7894
  These values should be passed into form data in pycurl.
  I have tried in this way but it gives me an error:</p>
  
  <pre><code>import pycurl
  import os
  try:
      # python 3
       from urllib.parse import urlencode
  except ImportError:
      # python 2
      from urllib import urlencode
  
  class FileReader:
      def __init__(self, fp):
           self.fp = fp
      def read_callback(self, size):
         return self.fp.read(size)
  c = pycurl.Curl()
  filesize = os.path.getsize('smaple.txt')
  with open('smaple.txt', 'r') as f:
      c.setopt(pycurl.POSTFIELDSIZE, filesize)
      c.setopt(pycurl.READFUNCTION, FileReader(f).read_callback)
      for line in f:
          print(line)
          c.setopt(c.URL, 'http://app.spongecell.com/api/queries')
          c.setopt(pycurl.HTTPHEADER, ['content-type: multipart/form-data'])
          post_data = {'user_credentials': 'xxxxxxx','query':'{campaign(id:line){name,status }}'}
  # Form data must be provided already urlencoded.
              postfields = urlencode(post_data)
  # Sets request method to POST,
  # Content-Type header to application/x-www-form-urlencoded
  # and data to send in request body.
              c.setopt(c.POSTFIELDS, postfields)
              c.perform()
              c.close()
  </code></pre>
  
  <blockquote>
    <p>ERROR:{"errors":[{"message":"Argument 'id' on Field 'campaign' has an invalid value. Expected type 'ID!'.","locations":[{"line":1,"column":2}],"fields":["query","campaign","id"]}]}</p>
  </blockquote>
  
  <p>Could anyone please help. As I am new to python.</p>