Hello I have a C# service, that takes a put request with no data, it just triggers an algorithm.
I am using urllib to make a request to this service, however I am getting a 411 error. This is because I am not supplying a data parameter.
req = urllib.request.Request(url, headers=headers, method='PUT')
try:
response = urllib.request.urlopen(req)
HTTPError: 411
If I try this:
req = urllib.request.Request(url, headers=headers,DATA="" method='PUT')
try:
response = urllib.request.urlopen(req)
TypeError: POST data should be bytes or an iterable of bytes. It cannot be of type str.
Can some one please help me, and please dont just say "huuu durr use requests" I cannot use imports. Thank you
Ok I solved this by:
req = urllib.request.Request(url, headers=headers,DATA=b'', method='PUT')
try:
response = urllib.request.urlopen(req)
Hope this helps