HTTP Removal Message Using Request Module

I use requests.deleteas follows:

r=requests.delete(url, json.dumps(data))

This gives me the following error:

r=requests.delete(url, json.dumps(data))
TypeError: delete() takes exactly 1 argument (2 given)

Why am I getting this error?

+4
source share
1 answer

The function requests.deletehas the following signature:

requests.delete(url, **kwargs)

There is only one required positional argument,, urland the rest must be keyword arguments, the same as for requests.request.

Yours json.dumps(data), of course, does not give the correct format for the keyword arguments. If you just want to pass this JSON as data, follow these steps:

requests.delete(url, data=json.dumps(data))
+4
source

Source: https://habr.com/ru/post/1545940/


All Articles