diff --git a/gnippy/rules.py b/gnippy/rules.py
index 0309b5d..f5f1d04 100644
--- a/gnippy/rules.py
+++ b/gnippy/rules.py
@@ -2,6 +2,11 @@
 
 import json
 
+try:
+    from urllib.parse import urlparse
+except:
+    from urlparse import urlparse
+
 import requests
 from six import string_types
 
@@ -82,6 +87,17 @@ def _post(conf, built_rules):
         error_text = "HTTP Response Code: %s, Text: '%s'" % (str(r.status_code), r.text)
         raise RuleAddFailedException(error_text)
 
+def _generate_delete_url(conf):
+    """
+        Generate the Rules URL for a DELETE request.
+    """
+    generated_url = _generate_rules_url(conf['url'])
+    parsed_url = urlparse(generated_url)
+    query = parsed_url.query
+    if query != '':
+        return generated_url.replace(query, query + "&_method=delete")
+    else:
+        return generated_url + "?_method=delete"
 
 def _delete(conf, built_rules):
     """
@@ -99,7 +115,7 @@ def _delete(conf, built_rules):
             built_rules: A single or list of built rules.
     """
     _check_rules_list(built_rules)
-    rules_url = _generate_rules_url(conf['url']) + "?_method=delete"
+    rules_url = _generate_delete_url(conf)
     delete_data = json.dumps(_generate_post_object(built_rules))
     r = requests.post(rules_url, auth=conf['auth'], data=delete_data)
     if not r.status_code in range(200,300):
diff --git a/setup.py b/setup.py
index 42ddcbc..d25cd66 100644
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
 import os
 import sys
 
-version = "0.5.0"
+version = "0.5.1"
 
 try:
     from setuptools import setup

Rules URL is incorrectly generated if endpoint URL has parameters
This does not work if `conf['url']` has params.

```
rules_url = _generate_rules_url(conf['url']) + "?_method=delete"
```

Example generated URL:

```
https://api.gnip.com:443/accounts/XXX/publishers/twitter/streams/track/prod/rules.json?client=2?_method=delete
```
diff --git a/gnippy/test/test_rules.py b/gnippy/test/test_rules.py
index 4310376..a79a857 100644
--- a/gnippy/test/test_rules.py
+++ b/gnippy/test/test_rules.py
@@ -258,6 +258,20 @@ class RulesTestCase(unittest.TestCase):
         r = rules.get_rules(config_file_path=test_utils.test_config_path)
         self.assertEqual(1, len(r))
 
+    def test_generate_delete_url_normal_case(self):
+        """ Check if the Delete URL is generated correctly. """
+        conf = { 'url': 'https://stream.gnip.com:443/accounts/XXX/publishers/twitter/streams/track/prod.json' }
+        url = rules._generate_delete_url(conf)
+        self.assertEqual('https://api.gnip.com:443/accounts/XXX/publishers/twitter/streams/track/prod/rules.json?_method=delete',
+            url)
+
+    def test_generate_delete_url_with_query(self):
+        """ Account for https://github.com/abh1nav/gnippy/issues/15 """
+        conf = { 'url': 'https://stream.gnip.com:443/accounts/XXX/publishers/twitter/streams/track/prod.json?client=2' }
+        url = rules._generate_delete_url(conf)
+        self.assertEqual('https://api.gnip.com:443/accounts/XXX/publishers/twitter/streams/track/prod/rules.json?client=2&_method=delete',
+            url)
+
     @mock.patch('requests.post', good_delete)
     def test_delete_rules_single(self):
         """ Delete one rule. """

pip install -e .
parse_log_pytest
requirements.txt
pytest
3.9
requirements-dev.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
cachetools==5.5.2
chardet==5.2.0
colorama==0.4.6
distlib==0.3.9
exceptiongroup==1.2.2
filelock==3.18.0
-e git+https://github.com/abh1nav/gnippy.git@f9fc42bf37cb9f415df18fd7f72a238d1cbd69e0#egg=gnippy
iniconfig==2.1.0
mock==1.0.1
nose==1.3.0
packaging==24.2
platformdirs==4.3.7
pluggy==1.5.0
pyproject-api==1.9.0
pytest==8.3.5
requests==2.8.1
six==1.10.0
tomli==2.2.1
tox==4.25.0
typing_extensions==4.13.0
virtualenv==20.29.3

name: gnippy
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - cachetools==5.5.2
      - chardet==5.2.0
      - colorama==0.4.6
      - distlib==0.3.9
      - exceptiongroup==1.2.2
      - filelock==3.18.0
      - iniconfig==2.1.0
      - mock==1.0.1
      - nose==1.3.0
      - packaging==24.2
      - platformdirs==4.3.7
      - pluggy==1.5.0
      - pyproject-api==1.9.0
      - pytest==8.3.5
      - requests==2.8.1
      - six==1.10.0
      - tomli==2.2.1
      - tox==4.25.0
      - typing-extensions==4.13.0
      - virtualenv==20.29.3
prefix: /opt/conda/envs/gnippy

gnippy/test/test_rules.py::RulesTestCase::test_generate_delete_url_normal_case gnippy/test/test_rules.py::RulesTestCase::test_generate_delete_url_with_query
gnippy/test/test_rules.py::RulesTestCase::test_add_many_rules_no_creds gnippy/test/test_rules.py::RulesTestCase::test_add_many_rules_not_ok gnippy/test/test_rules.py::RulesTestCase::test_add_many_rules_ok gnippy/test/test_rules.py::RulesTestCase::test_add_one_rule_no_creds gnippy/test/test_rules.py::RulesTestCase::test_add_one_rule_not_ok gnippy/test/test_rules.py::RulesTestCase::test_add_one_rule_ok gnippy/test/test_rules.py::RulesTestCase::test_build_post_object gnippy/test/test_rules.py::RulesTestCase::test_build_rule_bad_args gnippy/test/test_rules.py::RulesTestCase::test_build_rule_with_tag gnippy/test/test_rules.py::RulesTestCase::test_build_rule_without_tag gnippy/test/test_rules.py::RulesTestCase::test_build_rules_url gnippy/test/test_rules.py::RulesTestCase::test_build_rules_url_bad gnippy/test/test_rules.py::RulesTestCase::test_check_many_rules_ok gnippy/test/test_rules.py::RulesTestCase::test_check_one_rule_extra_stuff_in_rule gnippy/test/test_rules.py::RulesTestCase::test_check_one_rule_ok gnippy/test/test_rules.py::RulesTestCase::test_check_one_rule_typo_tag gnippy/test/test_rules.py::RulesTestCase::test_check_one_rule_typo_values gnippy/test/test_rules.py::RulesTestCase::test_check_rule_tag_none gnippy/test/test_rules.py::RulesTestCase::test_delete_rules_multiple gnippy/test/test_rules.py::RulesTestCase::test_delete_rules_single gnippy/test/test_rules.py::RulesTestCase::test_get_rules_bad_json gnippy/test/test_rules.py::RulesTestCase::test_get_rules_bad_status_code gnippy/test/test_rules.py::RulesTestCase::test_get_rules_no_rules_field_json gnippy/test/test_rules.py::RulesTestCase::test_get_rules_requests_get_exception gnippy/test/test_rules.py::RulesTestCase::test_get_rules_success_no_rules gnippy/test/test_rules.py::RulesTestCase::test_get_rules_success_one_rule
setup.py gnippy/rules.py
setup.py gnippy/rules.py