Consider the following template which is used to delete an entity from DB.
- test:
- group: "Basic Test"
- name: "Delete 10.24.39.202"
- url: "/v1/switch"
- method: 'DELETE'
- expected_status: [200]
- body: '{"ip_address": "10.24.39.202"}'
- headers: {'Authorization': 'Basic ZGV2ZWw6WjNGSmVFTlliMUJvYlVSclVrOWhXRVp3ZDIwNFUzQktSekpzTjBnMGVYVT0=',
'Content-Type': 'application/json'}
This doesn't work and I get the following error while decoding the body:
Traceback (most recent call last):
File "/home/stack/git/bwc/bwc/server/switch.py", line 1880, in delete
request = json.loads(self.request.body)
File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
From the changelogs, pyresttest supports body in delete request
1.6.0 Mon Oct 12 07:30:00 2015 -0400
BETA: support setting request body on all request types, if present
Allows (for example) DELETE methods that set a request body
Caveat: does not set length if 0
I am sure that I am using version 1.6.0. What could be the issue?