如何使用请求库执行HTTP DELETE请求
问题描述:
我正在使用requests软件包与toggl.com API进行交互。如何使用请求库执行HTTP DELETE请求
我可以执行GET和POST请求:
payload = {'some':'data'}
headers = {'content-type': 'application/json'}
url = "https://www.toggl.com/api/v6/" + data_description + ".json"
response = requests.post(url, data=json.dumps(payload), headers=headers,auth=HTTPBasicAuth(toggl_token, 'api_token'))
,但我不能似乎找到执行DELETE请求的方式。 这可能吗?使用替代
答
requests.deleterequests.post
payload = {'some':'data'}
headers = {'content-type': 'application/json'}
url = "https://www.toggl.com/api/v6/" + data_description + ".json"
response = requests.delete(url, data=json.dumps(payload), headers=headers,auth=HTTPBasicAuth(toggl_token, 'api_token'))