• Register
0 votes
48 views

Problem:

I am facing following error: post data should be bytes, an iterable of bytes, or a file object. it cannot be of type str.

6.1k points
reshown by

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

Try the following code:

urlCust = 'https://www.customdomain.com'
do = dict(param1="val1", param2="val2")

fo = urllib.parse.urlencode(do)
fo = fo.encode('utf-8')

req = urllib.request.Request(urlCust, fo)

Your issue lies in the way you were handling the dictionary.

12.8k points