sukhvir
sukhvir

Reputation: 5575

HTTP delete message using requests module

I am using the requests.delete as 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 do I get this error?

Upvotes: 4

Views: 744

Answers (1)

famousgarkin
famousgarkin

Reputation: 14126

The requests.delete function has the following signature:

requests.delete(url, **kwargs)

There's only one required positional argument, url, and the rest should be keyword arguments, the same as for requests.request function.

Your json.dumps(data) then surely doesn't give proper format of keyword arguments. If you just want to pass this JSON as data, do:

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

Upvotes: 4

Related Questions