Only urlencode params when using urllib.

The `requests` library expects a dict rather than
a urlencoded string for its 'data' parameter, and
behaves poorly when it receives a string instead.