Tannaa Tannaa - 1 year ago 129
HTTP Question

Non multi part post using pycurl

I am unable to post data to a rest server because the server doesn't know how to handle a multi part post requests,and it throws an error when it encounters a boundary.
Is there a way to make a non multi part post in pycurl?
Why does a post request need to be multi part?

Answer Source

A POST certainly doesn't have to be multipart, see this example from the pycurl docs that I also paste here:

c = pycurl.Curl()
c.setopt(c.URL, 'http://pycurl.io/tests/testpostvars.php')

post_data = {'field': 'value'}
# 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)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download