I am trying to urlencode this string before I submit.
queryString = 'eventName=' + evt.fields["eventName"] + '&' + 'eventDescription=' + evt.fields["eventDescription"];
I am trying to urlencode this string before I submit.
queryString = 'eventName=' + evt.fields["eventName"] + '&' + 'eventDescription=' + evt.fields["eventDescription"];
Try requests instead of urllib and you don't need to bother with urlencode!
EDIT:
If you need ordered name-value pairs or multiple values for a name then set params like so:
instead of using a dictionary.
In Python 3, this worked with me
You need to pass your parameters into
urlencode()
as either a mapping (dict), or a sequence of 2-tuples, like:Python 3 or above
Use:
Note that this does not do url encoding in the commonly used sense (look at the output). For that use
urllib.parse.quote_plus
.Python 3:
urllib.parse.quote_plus(string, safe='', encoding=None, errors=None)
for future references (ex: for python3)
Note that the urllib.urlencode does not always do the trick. The problem is that some services care about the order of arguments, which gets lost when you create the dictionary. For such cases, urllib.quote_plus is better, as Ricky suggested.