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?
An example of sending an HTTP DELETE request to the server. The Accept: */* request header tells the server that the client can accept any type of media in the server's response. In this HTTP DELETE request example, we are sending a DELETE request to the ReqBin echo URL.
The delete() method sends a DELETE request to the specified url. DELETE requests are made for deleting the specified resource (file, record etc).
This is an know scenario and Integration Server doesn't accept request body for HTTP DELETE Method. The only means to accept the content for DELETE method in IS is by passing the Query parameter.
The DELETE method deletes the specified resource. The CONNECT method establishes a tunnel to the server identified by the target resource. The OPTIONS method describes the communication options for the target resource. The TRACE method performs a message loop-back test along the path to the target resource.
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') )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With