jscott1989 / python-pipedrive

Python API for interacting with the pipedrive.com API
MIT License
93 stars 43 forks source link

Deleting organization is not working. #17

Open ishsonya opened 5 years ago

ishsonya commented 5 years ago
pipedrive.Pipedrive(token).organizations({"id": org_id}, method='DELETE')

yields an error: Please provide at least one item to delete

Looks it's because id is not handled properly in 'delete' requests. There are issued with bulk deletes as well (None of sent ids are deleted) adding

elif method == 'DELETE':
    if 'id' in data:
        putid = data.pop('id')
        uri = '{0}{1}/{2}?api_token={3}'.format(PIPEDRIVE_API_URL, endpoint, str(putid), str(self.api_token))
    response, data = self.http.request(uri, method=method, body=urlencode(data),
                                               headers={'Content-Type': 'application/x-www-form-urlencoded'})

to Pipedrive._request makes it work