47

I'm using the requests package for interacting with the toggl.com API.

I can perform GET and POST requests:

 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')) 

but i cant seem to find a way to perform a DELETE request. Is this possible?

2 Answers 2

89

Use requests.delete instead of requests.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') ) 
Sign up to request clarification or add additional context in comments.

1 Comment

what will the "data" Parameter do in a delete request? can we have conditional delete using the "data" parameter!
-1
import requests url = 'url.example.ap' headers = { 'content-type': "multipart/form-data; boundary=---- ", 'X-Auth-Token': ""anytoken"", 'Cache-Control': "no-cache" } r = requests.delete(url, headers=headers) n = os.write(sys.stdout.fileno(), r.content) print r.content == r.text 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.