Problem sending POST data to a login form with the character "ñ" (With Curl Works)

With curl works perfectly and I can Login. 

curl 'https://server.com/server.jsp?login' --data 'username=usernamex&PASSWORD=contrase%F1a' 

contrase%F1a15 means "contraseña15"

but when I try to send the same content with request I recieve the password is incorrect.

payload = 'username=usernamex&PASSWORD=contrase%F1a' 
login = "https://server.com/server.jsp?login"
r = requests.post(url=login,data=payload)
print r.text

How I can fix that? I try with serveral options. Like payload = {'password':'contraseña15" ..} and using json.dumps, but nothing, Always I recieve the same Result.

Please Help!


I also I try this

import urllib2, urllib
url = 'https://server.com/server.jsp?login'
data = urllib.urlencode({'USUARIO':'username','PASSWORD':'contrase%F1a15'})
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
d = response.read()
print d

And Nothing. Only works when I send the request from curl 


Something extra

With this curl I recieve the same result like with requests
curl 'https://server.com/server.jsp?login' --data 'USUARIO=username&PASSWORD=contraseña15'

And this works perfeclty.
curl 'https://server.com/server.jsp?login' --data 'USUARIO=username&PASSWORD=contrase%F1a15' 


All questions and people looking for help using requests should ask on StackOverflow. This is a place for known defects not support requests.


@sigmavirus24  I understand that.
but why works perfeclty with pycurl?

import pycurl
c = pycurl.Curl()
c.setopt(c.URL,  'https://server.com/server.jsp?login')
postfields = 'USUARIO=username&PASSWORD=contrase%F1a15'
c.setopt(c.VERBOSE, True)
c.setopt(c.POSTFIELDS, postfields)
c.perform()
c.close()

I think maybe is some bug with the encoding.

Because if I try the same with requests, this dont work.


In Details

import requests
import pycurl

login_url = "https://server.com/server.jsp?login"
postfields = 'username=usernamex&PASSWORD=contrase%F1a'

r = requests.post(login_url,postfields)
#This return a html with relatedd with error Login
print r.text

#And this Works perfectly.
c = pycurl.Curl()
c.setopt(c.URL, login_url)
c.setopt(c.VERBOSE, True)
c.setopt(c.POSTFIELDS, postfields)
c.perform()
c.close()


This was solved [here](https://stackoverflow.com/questions/31832015/issue-sending-post-data-to-a-login-form-with-the-character-%c3%b1-with-curl-works) as it should have been.

``` py
>>> req = requests.Request(method='POST', url='http://example.com', data={'username': 'usernamex', 'PASSWORD': 'contraseña15'})
>>> req
<Request [POST]>
>>> req.data
{'username': 'usernamex', 'PASSWORD': 'contrase\xc3\xb1a15'}
>>> req.prepare()
<PreparedRequest [POST]>
>>> p = _
>>> p.body
'username=usernamex&PASSWORD=contrase%C3%B1a15'
>>> req2 = requests.Request(method='POST', url='http://example.com', data='username=usernamex&PASSWORD=contrase%F1a15')
>>> req2.prepare().body
'username=usernamex&PASSWORD=contrase%F1a15'
>>> req3 = requests.Request(method='POST', url='http://example.com', data={'username': 'usernamex', 'PASSWORD': u'contraseña15'})
>>> req3.data
{'username': 'usernamex', 'PASSWORD': u'contrase\xf1a15'}
>>> req3.prepare().body
'username=usernamex&PASSWORD=contrase%C3%B1a15'
```

So the encoding there seems unnecessary on Python 2. The following is my output from a Python 3 interpreter:

``` py
>>> req = requests.Request(method='POST', url='http://example.com', data={'username': 'usernamex', 'PASSW
ORD': 'contraseña15'})
>>> req.prepare().body
'PASSWORD=contrase%C3%B1a15&username=usernamex'
>>> req2 = requests.Request(method='POST', url='http://example.com', data='username=usernamex&PASSWORD=co
ntrase%F1a15')
>>> req2.prepare().body
'username=usernamex&PASSWORD=contrase%F1a15'
>>> req3 = requests.Request(method='POST', url='http://example.com', data={'username': 'usernamex', 'PASSWORD': u'contraseña15'})
>>> req3.prepare().body
'PASSWORD=contrase%C3%B1a15&username=usernamex'
```

Again, I don't see a bug here.


Thanks for the reply, I hope this could help to another people with the same Issue.
Thanks @sigmavirus24