4

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?

sukhvir
  • 5,265
  • 6
  • 41
  • 43

1 Answers1

4

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))
famousgarkin
  • 13,687
  • 5
  • 58
  • 74