Skip to content

Commit 8df54d3

Browse files
authored
Merge pull request #26 from billdodd/fix/issue-25
Correct incorrect use of x-www-form-urlencoded for POST/PATCH/PUT
2 parents e4e2f58 + c15ea73 commit 8df54d3

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

README.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,22 @@ Perform a GET operation
9191
~~~~~~~~~~~~~~~~~~~~~~~~~
9292

9393
A simple GET operation can be performed to obtain the data present in any valid path.
94-
An example of rawget operation on the path "/redfish/v1/systems/1 is shown below:
94+
An example of rawget operation on the path "/redfish/v1/systems/1" is shown below:
9595

9696
.. code-block:: python
9797
9898
response = REDFISH_OBJ.get("/redfish/v1/systems/1", None)
9999
100+
Perform a POST operation
101+
~~~~~~~~~~~~~~~~~~~~~~~~~
102+
103+
A POST operation can be performed to create a resource or perform an action.
104+
An example of a POST operation on the path "/redfish/v1/systems/1/Actions/ComputerSystem.Reset" is shown below:
105+
106+
.. code-block:: python
107+
108+
body = {"ResetType": "GracefulShutdown"}
109+
response = REDFISH_OBJ.post("/redfish/v1/systems/1/Actions/ComputerSystem.Reset", body=body)
100110
101111
Logout the created session
102112
~~~~~~~~~~~~~~~~~~~~~~~~~

src/redfish/rest/v1.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,8 +735,10 @@ def _rest_request(self, path, method='GET', args=None, body=None, \
735735
if method == 'GET':
736736
reqpath += '?' + urlencode(args)
737737
elif method == 'PUT' or method == 'POST' or method == 'PATCH':
738-
headers['Content-Type'] = 'application/x-www-form-urlencoded'
739-
body = urlencode(args)
738+
LOGGER.warning('For POST, PUT and PATCH methods, the provided "args" parameter "{}" is ignored.'
739+
.format(args))
740+
if not body:
741+
LOGGER.warning('Use the "body" parameter to supply the request payload.')
740742

741743
restreq = RestRequest(reqpath, method=method, body=body)
742744

0 commit comments

Comments
 (0)